﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;

using CE.Mail;
using CE.Image;
using CE.Global;
using CE.Database;
using CE.CreditCard;
using CE.User;
using CE.PostCode;
using CE.CarInsurance;
using CE.Provider;
using CE.Security;
using CE.InputOut;
using CE.StreetDirectory;
using CE.Payment;

public partial class car_Insurance_new_proposalforms_liberty_proposal_form : System.Web.UI.Page
{
    public static Int64 _CarId, _CarMoreId, _UserId, _CXCTypeId, _ProviderId, _AgentId;
    public static DateTime _dtDOB1 = CE.Global.General.GetUTCDateTime();
    public static DateTime _dtDOB2 = CE.Global.General.GetUTCDateTime();
    public static DateTime _dtDOB3 = CE.Global.General.GetUTCDateTime();
    public static DateTime _dtDOB4 = CE.Global.General.GetUTCDateTime();
    public static DateTime _dtDOB5 = CE.Global.General.GetUTCDateTime();
    protected void Page_Load(object sender, EventArgs e)
    {
        //string isCXLive = CE.Configuration.MyConfigurationManager.GetAppSettingValue("IsCXLive").ToString();
        ///<summary>
        ///Teledirect Agent's Telemarketing (UserTypeId = SiteUser(200))
        ///Request.Params["uid"] - Email Address to retrieve CEID
        ///Request.Params["guid"] - Table tblCEUser's rowguid to check user request validation
        ///Request.Params["carid"] - Customer's Car Id
        ///Request.Params["carresultid"] - Customer's Car Result Id (Will be selected by Agent)
        ///Request.Params["providercompanyid"] -  Selected Result Item's ProviderCompanyId to validate proposal form
        ///</summary>
        if (Request.Params["uid"] != null && Request.Params["guid"] != null && Request.Params["carid"] != null
            && Request.Params["customerid"] != null && Request.Params["carresultid"] != null && Request.Params["providercompanyid"] != null)
        {
            lblProviderCompanyId.Text = Request.Params["providercompanyid"].ToString();
            if (lblProviderCompanyId.Text != "29")
            {
                Response.Redirect("~/");
            }
            else
            {
                if (!CheckAgentRequest(Request.Params["uid"].ToString(), Request.Params["guid"].ToString(), Request.Params["customerid"].ToString(), Request.Params["carid"].ToString(), Request.Params["carresultid"].ToString()))
                {
                    Response.Redirect("~/");
                }

            }

        }
        else
        {
            if (Session[General.AgentId] != null)
            {
                divAgent.Visible = true;
                lblAgentName.Text = Session[General.AgentName].ToString();
            }
            else
            {
                divAgent.Visible = false;
            }

            if (Session[CE.Global.General.UserId] != null && Session[CE.Global.General.UserTypeId] != null)
            {
                if (Convert.ToInt32(Session[CE.Global.General.UserTypeId]) !=
                     Convert.ToInt32(CE.Global.CEUserType.Customer) && Convert.ToInt32(Session[CE.Global.General.UserTypeId]) !=
                     Convert.ToInt32(CE.Global.CEUserType.Provider))
                {
                    Response.Redirect("~/car-insurance/login.aspx");
                }
            }
            else
            {
                Response.Redirect("~/car-insurance/login.aspx");
            }

            if (Session[General.CarId] == null || Session[General.CarPolicyId] == null)
            {
                Response.Redirect("~/car-insurance/profile.aspx");
            }
            if (Session[CE.Global.General.CarResultId] != null)
            {
                if (Session[General.ProviderCompanyId].ToString() != "29")
                {
                    Response.Redirect("~/user/viewresulthistory.aspx");
                }
            }
            else
            {
                Response.Redirect("~/user/viewresulthistory.aspx");
            }
        }


        if (!IsPostBack)
        {
            rdoNoConvicted.Checked = true;
            rdoNoDermeritPoints.Checked = true;
            rdoNoPhysicalimpairment.Checked = true;
            rdoNoInsuranceterminated.Checked = true;
            rdoNoRefused.Checked = true;



            //if (!CheckCarQuoteUpdateStatus())
            //{
            //    Response.Redirect("profile.aspx");
            //}

            //ibtSubmit.Attributes.Add("onclick", "return confirm('By pressing the submit button, you authorise CompareXpress to send your personal information to the partipating merchant of your choice. You therefore exempt CompareXpress from any liability relating to the sharing of this information with our participating merchant.');");
            //ibtSubmit.Attributes.Add("OnClick", "javascript:if (Page_ClientValidate('proposal')) { return confirm('By pressing the submit button, you authorise CompareXpress to send your personal information to the partipating merchant of your choice. You therefore exempt CompareXpress from any liability relating to the sharing of this information with our participating merchant.'); } return false;");

            lblDisclaimer.Text = CE.Configuration.MyConfigurationManager.GetAppSettingValue("LibertyCarProposalDisclaimer");
            #region Date Start & End

            //Sakthi on 21 Jan 2011 - Start
            //ddlDORegisteration.StartYear = CE.Global.General.GetUTCDateTime().Year - 25;
            //ddlDORegisteration.EndYear = CE.Global.General.GetUTCDateTime().Year;
            //Sakthi on 21 Jan 2011 - End

            ddlDOCancellation.StartYear = CE.Global.General.GetUTCDateTime().Year - 5;
            ddlDOCancellation.EndYear = CE.Global.General.GetUTCDateTime().Year + 1;

            //ddlInsurancefrom.StartYear = CE.Global.General.GetUTCDateTime().Year - 50;
            //ddlInsurancefrom.EndYear = CE.Global.General.GetUTCDateTime().Year;

            //ddlInsuranceto.StartYear = CE.Global.General.GetUTCDateTime().Year - 50;
            //ddlInsuranceto.EndYear = CE.Global.General.GetUTCDateTime().Year + 10;

            ddlDODemerit1.StartYear = CE.Global.General.GetUTCDateTime().Year - 3;
            ddlDODemerit1.EndYear = CE.Global.General.GetUTCDateTime().Year;

            ddlDODemerit2.StartYear = CE.Global.General.GetUTCDateTime().Year - 3;
            ddlDODemerit2.EndYear = CE.Global.General.GetUTCDateTime().Year;

            ddlDODemerit3.StartYear = CE.Global.General.GetUTCDateTime().Year - 3;
            ddlDODemerit3.EndYear = CE.Global.General.GetUTCDateTime().Year;

            ddlDODemerit4.StartYear = CE.Global.General.GetUTCDateTime().Year - 3;
            ddlDODemerit4.EndYear = CE.Global.General.GetUTCDateTime().Year;

            ddlDODemerit5.StartYear = CE.Global.General.GetUTCDateTime().Year - 3;
            ddlDODemerit5.EndYear = CE.Global.General.GetUTCDateTime().Year;

            ddlDODemerit6.StartYear = CE.Global.General.GetUTCDateTime().Year - 3;
            ddlDODemerit6.EndYear = CE.Global.General.GetUTCDateTime().Year;

            #endregion

            #region Load Combo

            InsurerDB _insurerdb = new InsurerDB();
            //DataTable dtPreInsurer = General.GetComboItem("PreInsurer", false);
            DataTable dtPreInsurerComp = _insurerdb.GetPreInsurer(100, 1);
            ddlCurInsuranceCompany.DataSource = dtPreInsurerComp;
            ddlCurInsuranceCompany.DataTextField = dtPreInsurerComp.Columns[0].ColumnName.ToString();
            ddlCurInsuranceCompany.DataValueField = dtPreInsurerComp.Columns[1].ColumnName.ToString();
            ddlCurInsuranceCompany.DataBind();
            ddlCurInsuranceCompany.Items.Insert(0, new ListItem("Select", "-1"));

            DataTable dtPreInsurerBank = _insurerdb.GetPreInsurer(100, 2);
            ddlHirePurchaseCompany.DataSource = dtPreInsurerBank;
            ddlHirePurchaseCompany.DataTextField = dtPreInsurerBank.Columns[0].ColumnName.ToString();
            ddlHirePurchaseCompany.DataValueField = dtPreInsurerBank.Columns[1].ColumnName.ToString();
            ddlHirePurchaseCompany.DataBind();
            ddlHirePurchaseCompany.Items.Insert(0, new ListItem("Select", "-1"));

            //DataTable dtNCD = General.GetComboItem("NCDNextClaim", false);
            //ddlNCD.DataSource = dtNCD;
            //ddlNCD.DataTextField = dtNCD.Columns[0].ColumnName.ToString();
            //ddlNCD.DataValueField = dtNCD.Columns[1].ColumnName.ToString();
            //ddlNCD.DataBind();
            //ddlNCD.Items.Insert(0, new ListItem("Select", "-2"));
            //dtNCD = null;

            int _year;
            int startyear = CE.Global.General.GetUTCDateTime().Year;
            int endyear = CE.Global.General.GetUTCDateTime().Year + 10;
            for (_year = endyear; _year >= startyear; _year--)
            {
                ddlCardExpiryYear.Items.Insert(0, new ListItem(_year.ToString("0000"), _year.ToString("00")));
            }
            ddlCardExpiryYear.Items.Insert(0, new ListItem("yyyy", "-1"));


            #endregion

            #region Set Property
            if (Session[CE.Global.General.UserPhoneNo] != null && Session[CE.Global.General.UserName] != null)
            {
                txtMobileNo.PhoneNo = Session[CE.Global.General.UserPhoneNo].ToString();
                txtName.Text = Session[CE.Global.General.UserName].ToString();
            }
            else if (lblCustomerId.Text != string.Empty)
            {
                txtName.Text = lblCustomerGivenName.Text;
                txtMobileNo.PhoneNo = lblCustomerMobileNo.Text;
            }

            LoadCarPolicyDetails();

            lblCarMoreDetailId.Text = "0";
            Session[General.CarMoreDetailId] = "0";

            if (Session[CE.Global.General.UserId] != null && Session[General.CarId] != null && Session[CE.Global.General.CarResultId] != null && Session[CE.Global.General.ProviderCompanyId] != null && Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()) == 29)
            {
                _CarId = Convert.ToInt64(Session[General.CarId].ToString());
                _UserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
                _CXCTypeId = Convert.ToInt64(Session[CE.Global.General.CarResultId].ToString());
                _ProviderId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
                ShowCarMoreDetail(_CarId, _UserId);
            }
            else if (lblCustomerId.Text != string.Empty && lblCarId.Text != string.Empty
                && lblProviderCompanyId.Text != string.Empty && lblCarResultId.Text != string.Empty)
            {
                _CarId = Convert.ToInt64(lblCarId.Text);
                _UserId = Convert.ToInt64(lblCustomerId.Text);
                _CXCTypeId = Convert.ToInt64(lblCarResultId.Text);
                _ProviderId = Convert.ToInt64(lblProviderCompanyId.Text);
                ShowCarMoreDetail(_CarId, _UserId);
            }

            #region Driver Discount
            MyDatabase _db = new MyDatabase();

            DataTable _dt = new DataTable("tblResultItem");

            _dt = _db.GetDataTable("Select NInfo5 from tblCarInsuranceTempResult WHERE CITempResultId = " + _CXCTypeId.ToString());
            if (_dt != null)
            {
                string _dicounttype = "";
                if (_dt.Rows[0][0] != null)
                {
                    _dicounttype = _dt.Rows[0][0].ToString();
                    if (_dicounttype == "1")
                    {
                        divDriverDiscount1.Visible = true;
                        divDriverDiscount2.Visible = false;
                        rfvDriverDiscount1.Enabled = true;
                        rfvDriverDiscount2.Enabled = false;
                    }
                    else if (_dicounttype == "2")
                    {
                        divDriverDiscount1.Visible = false;
                        divDriverDiscount2.Visible = true;
                        rfvDriverDiscount1.Enabled = false;
                        rfvDriverDiscount2.Enabled = true;
                    }
                    else
                    {
                        divDriverDiscount1.Visible = false;
                        divDriverDiscount2.Visible = false;
                        rfvDriverDiscount1.Enabled = false;
                        rfvDriverDiscount2.Enabled = false;
                    }
                }
            }

            _dt = null;
            _db = null;
            #endregion
            GetNCDProtection();
            #endregion

            #region Validation Effect

            txtName.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtName.ClientID + "','" + rfvName.ClientID + "','" + revName.ClientID + "')");
            txtPostCode.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtPostCode.ClientID + "','" + rfvPostCode.ClientID + "','" + revPostCode.ClientID + "')");
            txtUnit1.Attributes.Add("onblur", "ShowValidationEffect('" + txtUnit1.ClientID + "','" + rfvUnit1.ClientID + "')");
            txtUnit2.Attributes.Add("onblur", "ShowValidationEffect('" + txtUnit2.ClientID + "','" + rfvUnit2.ClientID + "')");
            txtAddress.Attributes.Add("onblur", "ShowValidationEffect('" + txtAddress.ClientID + "','" + rfvAddress.ClientID + "')");
            //txtEmpName.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtEmpName.ClientID + "','" + rfvEmpName.ClientID + "','" + revEmpName.ClientID + "')");
            txtEmpName.Attributes.Add("onblur", "ShowValidationEffect('" + txtEmpName.ClientID + "', '" + revEmpName.ClientID + "')");
            //ddlDrivetowestmalaysia.Attributes.Add("onblur", "ShowValidationEffect('" + ddlDrivetowestmalaysia.ClientID + "','" + rfvDrivetowestmalaysia.ClientID + "')");
            txtNCDReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtNCDReason.ClientID + "','" + rfvNCDReason.ClientID + "')");
            txtVehicleNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtVehicleNo.ClientID + "','" + rfvVehicleNo.ClientID + "')");
            //txtOdometerReading.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtOdometerReading.ClientID + "','" + rfvOdometerReading.ClientID + "','" + revOdometerReading.ClientID + "')");
            txtEngineNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtEngineNo.ClientID + "','" + rfvEngineNo.ClientID + "')");
            txtChassisNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtChassisNo.ClientID + "','" + rfvChassisNo.ClientID + "')");
            //txtEstimateMarketValue.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtEstimateMarketValue.ClientID + "','" + rfvEstimateMarketValue.ClientID + "','" + revEstimateMarketValue.ClientID + "')");
            ddlCurInsuranceCompany.Attributes.Add("onblur", "ShowValidationEffect('" + ddlCurInsuranceCompany.ClientID + "','" + rfvCurInsuranceCompany.ClientID + "')");
            txtInsVehicleNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtInsVehicleNo.ClientID + "','" + rfvInsVehicleNo.ClientID + "')");
            //txtInsPolicyNo.Attributes.Add("onblur", "ShowValidationEffect('" + txtInsPolicyNo.ClientID + "','" + rfvInsPolicyNo.ClientID + "')");
            //ddlNCD.Attributes.Add("onblur", "ShowValidationEffectMinusTwo('" + ddlNCD.ClientID + "','" + rfvNCD.ClientID + "')");
            txtVMReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtVMReason.ClientID + "','" + rfvVMReason.ClientID + "')");
            txtAccessories.Attributes.Add("onblur", "ShowValidationEffect('" + txtAccessories.ClientID + "','" + rfvAccessories.ClientID + "')");
            txtConvictedReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtConvictedReason.ClientID + "','" + rfvConvictedReason.ClientID + "')");
            txtDrivername1.Attributes.Add("onblur", "ShowValidationEffect('" + txtDrivername1.ClientID + "','" + rfvDrivername1.ClientID + "')");
            txtTotalpoints1.Attributes.Add("onblur", "ShowValidationEffect('" + txtTotalpoints1.ClientID + "','" + rfvTotalpoints1.ClientID + "')");
            txtOffencetype1.Attributes.Add("onblur", "ShowValidationEffect('" + txtOffencetype1.ClientID + "','" + rfvOffencetype1.ClientID + "')");
            txtPIReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtPIReason.ClientID + "','" + rfvPIReason.ClientID + "')");
            txtITReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtITReason.ClientID + "','" + rfvITReason.ClientID + "')");
            txtRefusedReason.Attributes.Add("onblur", "ShowValidationEffect('" + txtRefusedReason.ClientID + "','" + rfvRefusedReason.ClientID + "')");
            ddlHirePurchaseCompany.Attributes.Add("onblur", "ShowValidationEffect('" + ddlHirePurchaseCompany.ClientID + "','" + rfvHirePurchaseCompany.ClientID + "')");
            //txtHirePurchaseCompany.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtHirePurchaseCompany.ClientID + "','" + rfvHirePurchaseCompany.ClientID + "','" + revHirePurchaseCompany.ClientID + "')");
            //txtHPostCode.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtHPostCode.ClientID + "','" + rfvHPostCode.ClientID + "','" + revHPostCode.ClientID + "')");
            //txtHUnit1.Attributes.Add("onblur", "ShowValidationEffect('" + txtHUnit1.ClientID + "','" + rfvHUnit1.ClientID + "')");
            //txtHUnit2.Attributes.Add("onblur", "ShowValidationEffect('" + txtHUnit2.ClientID + "','" + rfvHUnit2.ClientID + "')");
            //txtHAddress.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtHAddress.ClientID + "','" + rfvHAddress.ClientID + "','" + revHAddress.ClientID + "')");

            txtNameoftheCard.Attributes.Add("onblur", "ShowValidationEffect('" + txtNameoftheCard.ClientID + "','" + rfvNameoftheCard.ClientID + "')");
            txtIssuingBank.Attributes.Add("onblur", "ShowValidationEffect('" + txtIssuingBank.ClientID + "','" + rfvIssuingBank.ClientID + "')");
            txtCardNo1.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardNo1.ClientID + "','" + rfvCardNo1.ClientID + "','" + revCardNo1.ClientID + "')");
            txtCardNo2.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardNo2.ClientID + "','" + rfvCardNo2.ClientID + "','" + revCardNo2.ClientID + "')");
            txtCardNo3.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardNo3.ClientID + "','" + rfvCardNo3.ClientID + "','" + revCardNo3.ClientID + "')");
            txtCardNo4.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardNo4.ClientID + "','" + rfvCardNo4.ClientID + "','" + revCardNo4.ClientID + "')");
            //txtCardExpiryMonth.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardExpiryMonth.ClientID + "','" + rfvCardExpiryMonth.ClientID + "','" + revCardExpiryMonth.ClientID + "')");
            //txtCardExpiryYear.Attributes.Add("onblur", "ShowValidationEffectTwo('" + txtCardExpiryYear.ClientID + "','" + rfvCardExpiryYear.ClientID + "','" + revCardExpiryYear.ClientID + "')");
            ddlCardExpiryMonth.Attributes.Add("onblur", "ShowValidationEffect('" + ddlCardExpiryMonth.ClientID + "','" + rfvCardExpiryMonth.ClientID + "')");
            ddlCardExpiryYear.Attributes.Add("onblur", "ShowValidationEffect('" + ddlCardExpiryYear.ClientID + "','" + rfvCardExpiryYear.ClientID + "')");

            txtDriverSurName1.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverSurName1.ClientID + "','" + rfvDriverSurName1.ClientID + "')");
            txtDriverSurName2.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverSurName2.ClientID + "','" + rfvDriverSurName2.ClientID + "')");
            txtDriverSurName3.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverSurName3.ClientID + "','" + rfvDriverSurName3.ClientID + "')");
            txtDriverSurName4.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverSurName4.ClientID + "','" + rfvDriverSurName4.ClientID + "')");
            txtDriverSurName5.Attributes.Add("onblur", "ShowValidationEffect('" + txtDriverSurName5.ClientID + "','" + rfvDriverSurName5.ClientID + "')");

            //rdoYesOtherInsurence.Attributes.Add("onblur", "CheckOtherInsurenceValidationCss();");
            //rdoNoOtherInsurence.Attributes.Add("onblur", "CheckOtherInsurenceValidationCss();");
            rdoYesVechicleModification.Attributes.Add("onblur", "CheckVechicleModificationValidationCss();");
            rdoNoVechicleModification.Attributes.Add("onblur", "CheckVechicleModificationValidationCss();");
            rdoYesAccessories.Attributes.Add("onblur", "CheckAccessoriesValidationCss();");
            rdoNoAccessories.Attributes.Add("onblur", "CheckAccessoriesValidationCss();");
            rdoYesConvicted.Attributes.Add("onblur", "CheckConvictedValidationCss();");
            rdoNoConvicted.Attributes.Add("onblur", "CheckConvictedValidationCss();");
            rdoYesDermeritPoints.Attributes.Add("onblur", "CheckDermeritPointsValidationCss();");
            rdoNoDermeritPoints.Attributes.Add("onblur", "CheckDermeritPointsValidationCss();");
            rdoYesPhysicalimpairment.Attributes.Add("onblur", "CheckPhysicalimpairmentValidationCss();");
            rdoNoPhysicalimpairment.Attributes.Add("onblur", "CheckPhysicalimpairmentValidationCss();");
            rdoYesInsuranceterminated.Attributes.Add("onblur", "CheckInsuranceterminatedValidationCss();");
            rdoNoInsuranceterminated.Attributes.Add("onblur", "CheckInsuranceterminatedValidationCss();");
            rdoYesHirePurchase.Attributes.Add("onblur", "CheckHirePurchaseValidationCss();");
            rdoNoHirePurchase.Attributes.Add("onblur", "CheckHirePurchaseValidationCss();");
            rdoVisa.Attributes.Add("onblur", "CheckCardTypeValidationCss();");
            rdoMasterCard.Attributes.Add("onblur", "CheckCardTypeValidationCss();");

            #endregion

            Session[General.ViewedDetailsId] = LogUserViewedHistory().ToString();

            //lnkBackTop.HRef = Request.UrlReferrer.ToString();
            //lnkBackBottom.HRef = Request.UrlReferrer.ToString();


            if (Request.Params["uid"] != null && Request.Params["guid"] != null && Request.Params["carid"] != null
            && Request.Params["customerid"] != null && Request.Params["carresultid"] != null && Request.Params["providercompanyid"] != null)
            {
                divAgentSave.Visible = true;

                //check for saved details
                LibertyCarMoreDetail _libertysavedetails = new LibertyCarMoreDetail();
                LibertyCarMoreDetailDB _libertydb = new LibertyCarMoreDetailDB();

                _libertysavedetails = _libertydb.GetCarMoreDetail(_CarId, _UserId);

                if (_libertysavedetails != null)
                {
                    LoadSavedDetails();
                }
            }


            if (Session[General.AgentId] != null)
            {
                divAgentSave.Visible = true;

                //check for saved details
                LibertyCarMoreDetail _libertysavedetails = new LibertyCarMoreDetail();
                LibertyCarMoreDetailDB _libertydb = new LibertyCarMoreDetailDB();

                _libertysavedetails = _libertydb.GetCarMoreDetail(_CarId, _UserId);

                if (_libertysavedetails != null)
                {
                   LoadSavedDetails();
                }
            }
          
        }
        //if (rdoYesOtherInsurence.Checked || rdoNoOtherInsurence.Checked) txtOI.Text = "1";
        if (rdoYesVechicleModification.Checked || rdoNoVechicleModification.Checked) txtVechicleModification.Text = "1";
        if (rdoYesAccessories.Checked || rdoNoAccessories.Checked) txtAccess.Text = "1";
        if (rdoYesConvicted.Checked || rdoNoConvicted.Checked) txtConvicted.Text = "1";
        if (rdoYesDermeritPoints.Checked || rdoNoDermeritPoints.Checked) txtDermeritPoints.Text = "1";
        if (rdoYesPhysicalimpairment.Checked || rdoNoPhysicalimpairment.Checked) txtPhysicalimpairment.Text = "1";
        if (rdoYesInsuranceterminated.Checked || rdoNoInsuranceterminated.Checked) txtInsuranceterminated.Text = "1";
        if (rdoYesRefused.Checked || rdoNoRefused.Checked) txtRefused.Text = "1";
        if (rdoYesHirePurchase.Checked || rdoNoHirePurchase.Checked) txtHirePurchase.Text = "1";
        if (rdoVisa.Checked || rdoMasterCard.Checked) txtCardType.Text = "1";

    }

    private bool CheckAgentRequest(string AgentId, string GUID, string CustomerId, string CarId, string CarResultId)
    {
        bool _retVal = false;
        try
        {
            lblCustomerId.Text = string.Empty;
            lblCustomerGivenName.Text = string.Empty;
            lblCustomerMobileNo.Text = string.Empty;
            lblCarId.Text = string.Empty;
            lblCarResultId.Text = string.Empty;

            Account _account = new Account();
            AccountDB _accountdb = new AccountDB();
            _account = _accountdb.CheckEmail(AgentId, 200);
            if (_account != null)
            {
                string _guid = _accountdb.GetGUID(_account.CEID);
                if (GUID.ToUpper() == _guid.ToUpper())
                {
                    lblAgentId.Text = _account.CEID.ToString();
                    if (!CheckSelectedStatus(CustomerId, CarId))
                    {
                        MyDatabase _db = new MyDatabase();
                        DataTable _dtResult = new DataTable();
                        string _spName = "[sprocCarInsuranceResultSelectSingleItem]";
                        SortedList _sPara = new SortedList();
                        _sPara.Add("@CECarId", Convert.ToInt64(CarId));
                        _sPara.Add("@RefCEUserId", Convert.ToInt64(CustomerId));
                        _sPara.Add("@CarResultId", Convert.ToInt64(CarResultId));
                        _dtResult = _db.GetDataTableBySP(_spName, _sPara);
                        if (_dtResult != null && _dtResult.Rows.Count == 1)
                        {
                            lblCustomerId.Text = CustomerId;
                            lblCarResultId.Text = CarResultId.ToString();
                            lblCarId.Text = CarId;
                            Profile _profile = new Profile();
                            ProfileDB _profiledb = new ProfileDB();
                            _profile = _profiledb.GetProfile(Convert.ToInt64(CustomerId));
                            if (_profile != null)
                            {
                                lblCustomerGivenName.Text = _profile.SurName;
                                if (_profile.FirstName.Length > 0)
                                {
                                    lblCustomerGivenName.Text += " " + _profile.FirstName;
                                }
                            }

                            Contact _contact = new Contact();
                            ContactDB _contactdb = new ContactDB();
                            _contact = _contactdb.GetContact(Convert.ToInt64(CustomerId));
                            if (_contact != null)
                            {
                                lblCustomerMobileNo.Text = _contact.Mobile;
                            }

                            _profile = null;
                            _profiledb = null;
                            _contact = null;
                            _contactdb = null;
                            _dtResult = null;
                            _db = null;
                            _retVal = true;
                        }
                        else
                        {

                        }
                    }
                    else
                    {
                        _retVal = false;
                        //ibtSubmit.Enabled = false;
                        //ibtSubmit.Visible = false;
                        //lblHeaderMessage.Text = "This application form have been already sent to Liberty Insurance.";
                    }
                }
                else
                {
                    _retVal = false;
                }
            }
            else
            {
                _retVal = false;
            }
        }
        catch (Exception Ex)
        {
            _retVal = false;
        }
        return _retVal;
    }

    private bool CheckSelectedStatus(string CustomerId, string CarId)
    {
        MyDatabase _db = new MyDatabase();
        string _strSQLCheckSelected = "select COUNT(CISelectItemId) from tblCarInsuranceSelectItem Where Status = 1 And RefCEUserId = " + CustomerId + " And CECarId = " + CarId;
        object _objSelectStatus = _db.ExecuteScalarSqlStatement(_strSQLCheckSelected);

        bool _IsSelected = false;
        if (_objSelectStatus != null)
        {
            _IsSelected = Convert.ToInt32(_objSelectStatus) > 0;
        }
        _db = null;
        return _IsSelected;
    }

    protected void ibtSubmit_Click(object sender, ImageClickEventArgs e)
    {
        //if (Session[CE.Global.General.CarResultId] != null)
        //{
        //    if (Session[General.ProviderCompanyId].ToString() != "29")
        //    {
        //        Response.Redirect("~/user/viewresulthistory.aspx");
        //    }
        //}
        //else
        //{
        //    Response.Redirect("~/user/viewresulthistory.aspx");
        //}

        if (rdoYesConvicted.Checked || rdoYesDermeritPoints.Checked || rdoYesPhysicalimpairment.Checked || rdoYesInsuranceterminated.Checked || rdoYesRefused.Checked)
        {
            lblMessage.Text = "Unfortunately, you are unable to proceed to complete this online proposal form.";
        }
        else
        {
            CheckValidation();
            ChangeValidationEffectServerSide("proposal");
            if (IsValid)
            {
                //if (!CheckCarQuoteUpdateStatus())
                //{
                //    Response.Redirect("profile.aspx");
                //}
                if (lblCarId.Text != string.Empty && lblCustomerId.Text != string.Empty
                    && lblCarResultId.Text != string.Empty && lblProviderCompanyId.Text != string.Empty)
                {
                    _CarId = Convert.ToInt64(lblCarId.Text);
                    _UserId = Convert.ToInt64(lblCustomerId.Text);
                    _CXCTypeId = Convert.ToInt64(lblCarResultId.Text);
                    _ProviderId = Convert.ToInt64(lblProviderCompanyId.Text);
                    _CarMoreId = Convert.ToInt64(lblCarMoreDetailId.Text);
                    _AgentId = Convert.ToInt64(lblAgentId.Text);
                }
                else if (Session[General.CarId] != null && Session[General.UserId] != null
                    && Session[General.CarResultId] != null && Session[General.ProviderCompanyId] != null)
                {
                    _CarId = Convert.ToInt64(Session[General.CarId].ToString());
                    _UserId = Convert.ToInt64(Session[General.UserId].ToString());
                    _CXCTypeId = Convert.ToInt64(Session[General.CarResultId].ToString());
                    _ProviderId = Convert.ToInt64(Session[General.ProviderCompanyId].ToString());
                    _CarMoreId = Convert.ToInt64(Session[General.CarMoreDetailId].ToString());
                    if (Session[General.AgentId] != null)
                    {
                        _AgentId = Convert.ToInt64(Session[General.AgentId].ToString());
                    }
                    else
                    {
                        _AgentId = 0;
                    }
                }

                Int64 _carmoreresult = 0;
                Int64 demeritresult = 0;
                Int64 driverresult = 0;
                LibertyCarMoreDetail _libertycarmoredetail = new LibertyCarMoreDetail();
                LibertyCarMoreDetailDB _libertycarmoredetaildb = new LibertyCarMoreDetailDB();

                _libertycarmoredetail.CECarMoreDetailId = _CarMoreId;
                _libertycarmoredetail.NInfo1 = _AgentId;
                //if (Session[General.CarMoreDetailId] != null)
                //{
                //    _libertycarmoredetail.CECarMoreDetailId = Convert.ToInt64(Session[General.CarMoreDetailId].ToString());
                //}
                //else
                //{
                //    _libertycarmoredetail.CECarMoreDetailId = 0;
                //}
                _libertycarmoredetail.CECarId = _CarId;
                _libertycarmoredetail.ProviderCompanyId = _ProviderId;
                _libertycarmoredetail.Name = txtName.Text.ToUpper();
                _libertycarmoredetail.PostalCode = txtPostCode.Text.Trim();
                _libertycarmoredetail.UnitNo = txtUnit1.Text.Trim();
                _libertycarmoredetail.HomeNo = txtUnit2.Text.Trim();
                _libertycarmoredetail.Address = txtAddress.Text.Trim();
                _libertycarmoredetail.MobileNo = txtMobileNo.GetPhoneNo();
                _libertycarmoredetail.HomePhoneNo = txtResidentialPhoneNo.GetPhoneNo();
                _libertycarmoredetail.OfficePhoneNo = txtOfficePhoneNo.GetPhoneNo();
                _libertycarmoredetail.NRICNo = ddlIdNumber.GetIdNumber();
                _libertycarmoredetail.Nationality = ddlNationality.GetNationality();
                _libertycarmoredetail.EmpNameandTrade = txtEmpName.Text.Trim();
                _libertycarmoredetail.HasDriveWestMalaysia = ddlDrivetowestmalaysia.SelectedValue;
                _libertycarmoredetail.NCDReason = ddlNCDReason.SelectedValue;
                if (ddlNCDReason.SelectedValue == "Others")
                {
                    _libertycarmoredetail.NCDOtherReason = txtNCDReason.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.NCDOtherReason = "";
                }
                _libertycarmoredetail.VechicleNo = txtVehicleNo.Text.Trim();
                //_libertycarmoredetail.OdometerReading = txtOdometerReading.Text.Trim();
                _libertycarmoredetail.DateofRegistration = ddlDORegisteration.GetDate();
                _libertycarmoredetail.EngineNo = txtEngineNo.Text.Trim();
                _libertycarmoredetail.ChassisNo = txtChassisNo.Text.Trim();
                //_libertycarmoredetail.EstimateMarketValue = Convert.ToSingle(txtEstimateMarketValue.Text.Trim());
                _libertycarmoredetail.HasHirePurchase = rdoYesHirePurchase.Checked;
                if (rdoYesHirePurchase.Checked == true)
                {
                    _libertycarmoredetail.HPCompanyName = ddlHirePurchaseCompany.Text;
                    //_libertycarmoredetail.HPCPostalCode = txtHPostCode.Text.Trim();
                    //_libertycarmoredetail.HPCUnitNo = txtHUnit1.Text.Trim();
                    //_libertycarmoredetail.HPCHomeNo = txtHUnit2.Text.Trim();
                    //_libertycarmoredetail.HPCAddress = txtHAddress.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.HPCompanyName = "";
                    //_libertycarmoredetail.HPCPostalCode = "";
                    //_libertycarmoredetail.HPCUnitNo = "";
                    //_libertycarmoredetail.HPCHomeNo = "";
                    //_libertycarmoredetail.HPCAddress = "";
                }
                _libertycarmoredetail.HasPreInsurer = true; //rdoYesOtherInsurence.Checked;
                //if (rdoYesOtherInsurence.Checked == true)
                if (ddlCurInsuranceCompany.Text != "177")
                {
                    _libertycarmoredetail.PreInsurerName = ddlCurInsuranceCompany.Text;
                    _libertycarmoredetail.PreInsVechicleNo = txtInsVehicleNo.Text.Trim();
                    //_libertycarmoredetail.PreInsPolicyNo = txtInsPolicyNo.Text.Trim();
                    _libertycarmoredetail.PreInsExpiryDate = ddlDOCancellation.GetDate();
                    _libertycarmoredetail.NCDEntitlement = lblNCDvalue.Text;
                    //_libertycarmoredetail.NCDEntitlement = ddlNCD.Text;
                }
                else
                {
                    _libertycarmoredetail.PreInsurerName = ddlCurInsuranceCompany.Text;
                    _libertycarmoredetail.PreInsVechicleNo = "";
                    //_libertycarmoredetail.PreInsPolicyNo = "";
                    _libertycarmoredetail.PreInsExpiryDate = new DateTime(1900, 1, 1);
                    _libertycarmoredetail.NCDEntitlement = "";
                }
                _libertycarmoredetail.HasVechicleModified = rdoYesVechicleModification.Checked;
                if (rdoYesVechicleModification.Checked == true)
                {
                    _libertycarmoredetail.VechicleModifyReason = txtVMReason.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.VechicleModifyReason = "";
                }
                _libertycarmoredetail.HasAccessory = rdoYesAccessories.Checked;
                if (rdoYesAccessories.Checked == true)
                {
                    _libertycarmoredetail.AccessoryDescription = txtAccessories.Text;
                }
                else
                {
                    _libertycarmoredetail.AccessoryDescription = "";
                }
                //_libertycarmoredetail.InsuranceFromDate = ddlInsurancefrom.GetDate();
                //_libertycarmoredetail.InsuranceToDate = ddlInsuranceto.GetDate();
                _libertycarmoredetail.HasConvictedMoterOffence = rdoYesConvicted.Checked;
                if (rdoYesConvicted.Checked == true)
                {
                    _libertycarmoredetail.ConvictedReason = txtConvictedReason.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.ConvictedReason = "";
                }
                _libertycarmoredetail.HasDemeritPoints = rdoYesDermeritPoints.Checked;
                _libertycarmoredetail.HasPhysicalImpairment = rdoYesPhysicalimpairment.Checked;
                if (rdoYesPhysicalimpairment.Checked == true)
                {
                    _libertycarmoredetail.PhysicalImpairmentReason = txtPIReason.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.PhysicalImpairmentReason = "";
                }
                _libertycarmoredetail.HasInsuranceTerminated = rdoYesInsuranceterminated.Checked;
                if (rdoYesInsuranceterminated.Checked == true)
                {
                    _libertycarmoredetail.InsuranceTerminatedReason = txtITReason.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.InsuranceTerminatedReason = "";
                }

                if (rdoCreditCard.Checked == true)
                {
                    _libertycarmoredetail.PamentType = "CreditCard";
                }
                else if (rdoCash.Checked == true)
                {
                    _libertycarmoredetail.PamentType = "Cash";
                }

                _libertycarmoredetail.QuoteRefNo = lblQRefNo.Text.Trim();

                _libertycarmoredetail.RefCEUserId = _UserId;
                _libertycarmoredetail.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
                _libertycarmoredetail.Status = true;
                _libertycarmoredetail.CarResultId = _CXCTypeId;

                if (rdoYesRefused.Checked == true)
                    _libertycarmoredetail.Info1 = "1";
                else
                    _libertycarmoredetail.Info1 = "0";

                if (rdoYesRefused.Checked == true)
                {
                    _libertycarmoredetail.Info2 = txtRefusedReason.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.Info2 = "";
                }

                if (rdoYes.Checked == true)
                {
                    _libertycarmoredetail.Info3 = "1";
                }
                else
                {
                    _libertycarmoredetail.Info3 = "0";
                }

                LibertyCarMoreDetail _libertycarmoredetailCheck = new LibertyCarMoreDetail();
                _libertycarmoredetailCheck = _libertycarmoredetaildb.GetCarMoreDetail(_CarId, _UserId);

                if (_libertycarmoredetailCheck != null) //existing
                {
                    _libertycarmoredetail.CECarMoreDetailId = _libertycarmoredetailCheck.CECarMoreDetailId;
                }

                _carmoreresult = _libertycarmoredetaildb.Insert(_libertycarmoredetail);

                if (_carmoreresult > 0)
                {
                    if (lblCarId.Text != string.Empty && lblCustomerId.Text != string.Empty)
                    {
                        lblCarMoreDetailId.Text = _carmoreresult.ToString();
                    }
                    else if (Session[General.CarId] != null && Session[General.UserId] != null)
                    {
                        Session[CE.Global.General.CarMoreDetailId] = _carmoreresult.ToString();
                    }

                    Int64 _paymentresult = 0;
                    if (rdoCreditCard.Checked)
                    {
                        Payment _payment = new Payment();
                        PaymentDB _paymentdb = new PaymentDB();

                        _payment.CXPaymentId = 0;
                        _payment.RefId = _CarId;
                        _payment.ProviderCompanyId = _ProviderId;
                        _payment.InsuranceType = "CI";
                        _payment.NameoftheCard = txtNameoftheCard.Text.ToUpper();
                        _payment.IssuingBankName = txtIssuingBank.Text.Trim();
                        _payment.CreditCardNo = txtCardNo1.Text.Trim() + "" + txtCardNo2.Text.Trim() + "" + txtCardNo3.Text.Trim() + "" + txtCardNo4.Text.Trim();
                        _payment.CardExpiryMonth = ddlCardExpiryMonth.Text;
                        _payment.CardExpiryYear = ddlCardExpiryYear.Text;
                        if (rdoAnnualPayment.Checked)
                        {
                            _payment.InstallmentType = 1;
                        }
                        else if (rdoMonthlyPayment.Checked)
                        {
                            _payment.InstallmentType = 2;
                        }
                        else if (rdoMonthlyPayment6Months.Checked)
                        {
                            _payment.InstallmentType = 3;
                        }
                        if (rdoVisa.Checked == true)
                        {
                            _payment.CardType = "Visa";
                        }
                        else
                        {
                            _payment.CardType = "MasterCard";
                        }
                        _payment.Status = true;
                        if (_UserId != 0)
                        {
                            _payment.RefCEUserId = _UserId;
                        }
                        else
                        {
                            _payment.RefCEUserId = 0;
                        }
                        _paymentresult = _paymentdb.Insert(_payment);
                    }
                    else
                    {
                        _paymentresult = 1;
                    }
                    if (_paymentresult > 0)
                    {
                        if (rdoYesDermeritPoints.Checked == true)
                        {
                            //Int64 CarId = Convert.ToInt64(Session[General.CarId].ToString());
                            //Int64 CEId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
                            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
                            _cardriverdemeritpointsdb.DeleteCarDriverDemeritPoints(_CarId, _carmoreresult, _UserId);
                            _cardriverdemeritpointsdb = null;

                            if (!SaveDemeritPoints())
                            {
                                lblMessage.Text = "Accessary failed to save!";
                            }
                            else
                            {
                                demeritresult = 1;
                            }
                        }
                        else
                        {
                            demeritresult = 1;
                        }
                        if (demeritresult > 0)
                        {
                            if (txtDriverCount.Text.Trim() != "0")
                            {
                                if (!UpdateDriverDetails())
                                {
                                    lblMessage.Text = "Car Drivers failed to save!";
                                }
                                else
                                {
                                    driverresult = 1;
                                }
                            }
                            else
                            {
                                driverresult = 1;
                            }

                            if (driverresult > 0)
                            {

                                Int64 _statusresult = 0;
                                _libertycarmoredetail.CECarId = _CarId;
                                _libertycarmoredetail.CarResultId = _CXCTypeId;

                                _statusresult = _libertycarmoredetaildb.UpdateStatus(_libertycarmoredetail);



                                UserConfirmation _userconfirm = new UserConfirmation();
                                UserConfirmationDB _userconfirmdb = new UserConfirmationDB();
                                _userconfirm.ConfirmationType = "CI";
                                _userconfirm.CurrentStep = 4;
                                //_userconfirm.UserResultId = Convert.ToInt64(Session[General.CarResultId].ToString());
                                _userconfirm.UserSelectedId = _CXCTypeId;
                                _userconfirm.FirstStepId = _CarId;
                                _userconfirm.RefCEUserId = _UserId;
                                _userconfirm.IsConfirm = true;
                                _userconfirm.ResultStatus = "Complete";
                                _userconfirm.IsComplete = true;
                                Int64 _result = _userconfirmdb.Insert(_userconfirm);
                                if ((_result > 0) && (_statusresult > 0))
                                {
                                    //GenerateExcelProposalForm(Convert.ToInt64(Session[CE.Global.General.CarId]));
                                    //GeneratePDFProposalForm(Convert.ToInt64(Session[CE.Global.General.CarId]));
                                    ProposalNotification();
                                    string _providerEncodeId = Encode(_ProviderId.ToString());
                                    string _refid = "";
                                    string convertno = General.GetRefNumber(_CarId);
                                    _refid = "L" + convertno;

                                    General.ClearAllSession(this.Page, "ALL");
                                    Response.Redirect("~/car-insurance/usermessage.aspx?pcid=" + _providerEncodeId + "&ref=" + _refid);
                                }
                                else
                                {
                                    lblMessage.Text = "Can't update confirmation status.";
                                }

                                //Response.Redirect("declaration.aspx");
                            }
                        }
                    }
                    else
                    {
                        lblMessage.Text = "Payment Details Saved Failed.";
                    }
                }
            }
        }
    }

    protected void imgbtnSave_Click(object sender, ImageClickEventArgs e)
    {
        if (rdoYesConvicted.Checked || rdoYesDermeritPoints.Checked || rdoYesPhysicalimpairment.Checked || rdoYesInsuranceterminated.Checked || rdoYesRefused.Checked)
        {
            lblMessage.Text = "Unfortunately, you are unable to proceed to complete this online proposal form.";
        }
        else
        {
            CheckValidationSave();
            ChangeValidationEffectServerSideSave("tempsaveproposal");
            if (IsValid)
            {
                if (lblCarId.Text != string.Empty && lblCustomerId.Text != string.Empty
                       && lblCarResultId.Text != string.Empty && lblProviderCompanyId.Text != string.Empty)
                {
                    _CarId = Convert.ToInt64(lblCarId.Text);
                    _UserId = Convert.ToInt64(lblCustomerId.Text);
                    _CXCTypeId = Convert.ToInt64(lblCarResultId.Text);
                    _ProviderId = Convert.ToInt64(lblProviderCompanyId.Text);
                    _CarMoreId = Convert.ToInt64(lblCarMoreDetailId.Text);
                    _AgentId = Convert.ToInt64(lblAgentId.Text);
                }
                else if (Session[General.CarId] != null && Session[General.UserId] != null
                       && Session[General.CarResultId] != null && Session[General.ProviderCompanyId] != null)
                {
                    _CarId = Convert.ToInt64(Session[General.CarId].ToString());
                    _UserId = Convert.ToInt64(Session[General.UserId].ToString());
                    _CXCTypeId = Convert.ToInt64(Session[General.CarResultId].ToString());
                    _ProviderId = Convert.ToInt64(Session[General.ProviderCompanyId].ToString());
                    _CarMoreId = Convert.ToInt64(Session[General.CarMoreDetailId].ToString());
                    if (Session[General.AgentId] != null)
                    {
                        _AgentId = Convert.ToInt64(Session[General.AgentId].ToString());
                    }
                    else
                    {
                        _AgentId = 0;
                    }
                }

                Int64 _carmoreresult = 0;
                Int64 demeritresult = 0;
                Int64 driverresult = 0;
                LibertyCarMoreDetail _libertycarmoredetail = new LibertyCarMoreDetail();
                LibertyCarMoreDetail _libertycarmoredetailCheck = new LibertyCarMoreDetail();
                LibertyCarMoreDetailDB _libertycarmoredetaildb = new LibertyCarMoreDetailDB();


                _libertycarmoredetail.CECarMoreDetailId = _CarMoreId;
                _libertycarmoredetail.NInfo1 = _AgentId;
                _libertycarmoredetail.CECarId = _CarId;
                _libertycarmoredetail.ProviderCompanyId = _ProviderId;
                _libertycarmoredetail.Name = txtName.Text.ToUpper();
                _libertycarmoredetail.PostalCode = txtPostCode.Text.Trim();
                _libertycarmoredetail.UnitNo = txtUnit1.Text.Trim();
                _libertycarmoredetail.HomeNo = txtUnit2.Text.Trim();
                _libertycarmoredetail.Address = txtAddress.Text.Trim();
                _libertycarmoredetail.MobileNo = txtMobileNo.GetPhoneNo();
                _libertycarmoredetail.HomePhoneNo = txtResidentialPhoneNo.GetPhoneNo();
                _libertycarmoredetail.OfficePhoneNo = txtOfficePhoneNo.GetPhoneNo();
                _libertycarmoredetail.NRICNo = ddlIdNumber.GetIdNumber();
                _libertycarmoredetail.Nationality = ddlNationality.GetNationality();
                _libertycarmoredetail.EmpNameandTrade = txtEmpName.Text.Trim();
                _libertycarmoredetail.HasDriveWestMalaysia = ddlDrivetowestmalaysia.SelectedValue;
                _libertycarmoredetail.NCDReason = ddlNCDReason.SelectedValue;
                if (ddlNCDReason.SelectedValue == "Others")
                {
                    _libertycarmoredetail.NCDOtherReason = txtNCDReason.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.NCDOtherReason = "";
                }
                _libertycarmoredetail.VechicleNo = txtVehicleNo.Text.Trim();
                _libertycarmoredetail.DateofRegistration = ddlDORegisteration.GetDate();
                _libertycarmoredetail.EngineNo = txtEngineNo.Text.Trim();
                _libertycarmoredetail.ChassisNo = txtChassisNo.Text.Trim();
                _libertycarmoredetail.HasHirePurchase = rdoYesHirePurchase.Checked;
                if (rdoYesHirePurchase.Checked == true)
                {
                    _libertycarmoredetail.HPCompanyName = ddlHirePurchaseCompany.Text;
                }
                else
                {
                    _libertycarmoredetail.HPCompanyName = "";
                }
                _libertycarmoredetail.HasPreInsurer = true;
                if (ddlCurInsuranceCompany.Text != "177")
                {
                    _libertycarmoredetail.PreInsurerName = ddlCurInsuranceCompany.Text;
                    _libertycarmoredetail.PreInsVechicleNo = txtInsVehicleNo.Text.Trim();
                    _libertycarmoredetail.PreInsExpiryDate = ddlDOCancellation.GetDate();
                    _libertycarmoredetail.NCDEntitlement = lblNCDvalue.Text;
                }
                else
                {
                    _libertycarmoredetail.PreInsurerName = ddlCurInsuranceCompany.Text;
                    _libertycarmoredetail.PreInsVechicleNo = "";
                    _libertycarmoredetail.PreInsExpiryDate = new DateTime(1900, 1, 1);
                    _libertycarmoredetail.NCDEntitlement = "";
                }
                _libertycarmoredetail.HasVechicleModified = rdoYesVechicleModification.Checked;
                if (rdoYesVechicleModification.Checked == true)
                {
                    _libertycarmoredetail.VechicleModifyReason = txtVMReason.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.VechicleModifyReason = "";
                }
                _libertycarmoredetail.HasAccessory = rdoYesAccessories.Checked;
                if (rdoYesAccessories.Checked == true)
                {
                    _libertycarmoredetail.AccessoryDescription = txtAccessories.Text;
                }
                else
                {
                    _libertycarmoredetail.AccessoryDescription = "";
                }

                _libertycarmoredetail.HasConvictedMoterOffence = rdoYesConvicted.Checked;
                if (rdoYesConvicted.Checked == true)
                {
                    _libertycarmoredetail.ConvictedReason = txtConvictedReason.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.ConvictedReason = "";
                }
                _libertycarmoredetail.HasDemeritPoints = rdoYesDermeritPoints.Checked;
                _libertycarmoredetail.HasPhysicalImpairment = rdoYesPhysicalimpairment.Checked;
                if (rdoYesPhysicalimpairment.Checked == true)
                {
                    _libertycarmoredetail.PhysicalImpairmentReason = txtPIReason.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.PhysicalImpairmentReason = "";
                }
                _libertycarmoredetail.HasInsuranceTerminated = rdoYesInsuranceterminated.Checked;
                if (rdoYesInsuranceterminated.Checked == true)
                {
                    _libertycarmoredetail.InsuranceTerminatedReason = txtITReason.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.InsuranceTerminatedReason = "";
                }

                if (rdoCreditCard.Checked == true)
                {
                    _libertycarmoredetail.PamentType = "CreditCard";
                }
                else if (rdoCash.Checked == true)
                {
                    _libertycarmoredetail.PamentType = "Cash";
                }

                _libertycarmoredetail.QuoteRefNo = lblQRefNo.Text.Trim();

                _libertycarmoredetail.RefCEUserId = _UserId;
                _libertycarmoredetail.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
                _libertycarmoredetail.Status = true;
                _libertycarmoredetail.CarResultId = _CXCTypeId;

                if (rdoYesRefused.Checked == true)
                    _libertycarmoredetail.Info1 = "1";
                else
                    _libertycarmoredetail.Info1 = "0";

                if (rdoYesRefused.Checked == true)
                {
                    _libertycarmoredetail.Info2 = txtRefusedReason.Text.Trim();
                }
                else
                {
                    _libertycarmoredetail.Info2 = "";
                }

                if (rdoYes.Checked == true)
                {
                    _libertycarmoredetail.Info3 = "1";
                }
                else
                {
                    _libertycarmoredetail.Info3 = "0";
                }


                _libertycarmoredetailCheck = _libertycarmoredetaildb.GetCarMoreDetail(_CarId, _UserId);

                if (_libertycarmoredetailCheck != null) //existing
                {
                    _libertycarmoredetail.CECarMoreDetailId = _libertycarmoredetailCheck.CECarMoreDetailId;

                }

                _carmoreresult = _libertycarmoredetaildb.Insert(_libertycarmoredetail);

                if (_carmoreresult > 0)
                {
                    lblMessageSave.Text = "Proposal Details Saved (except payment details).";
                }
                else
                {
                    lblMessageSave.Text = "Proposal Details can't be save.";
                }
            }

        }
    }

    protected void LoadSavedDetails()
    {
        LibertyCarMoreDetail _libertycarmoredetailCheck = new LibertyCarMoreDetail();
        LibertyCarMoreDetailDB _libertycarmoredetaildb = new LibertyCarMoreDetailDB();

        _libertycarmoredetailCheck = _libertycarmoredetaildb.GetCarMoreDetail(_CarId, _UserId);

        if (_libertycarmoredetailCheck != null)
        {
            txtName.Text = _libertycarmoredetailCheck.Name;
            txtPostCode.Text = _libertycarmoredetailCheck.PostalCode;
            txtUnit1.Text = _libertycarmoredetailCheck.UnitNo;
            txtUnit2.Text = _libertycarmoredetailCheck.HomeNo;
            txtAddress.Text = _libertycarmoredetailCheck.Address;
            txtMobileNo.PhoneNo = _libertycarmoredetailCheck.MobileNo.ToString();
            txtResidentialPhoneNo.PhoneNo = _libertycarmoredetailCheck.HomePhoneNo.ToString();
            txtOfficePhoneNo.PhoneNo = _libertycarmoredetailCheck.OfficePhoneNo.ToString();
            ddlIdNumber.Prefix = _libertycarmoredetailCheck.NRICNo.Substring(0, 1);
            ddlIdNumber.Postfix = _libertycarmoredetailCheck.NRICNo.Substring(8, 1);
            ddlIdNumber.IDNumber = _libertycarmoredetailCheck.NRICNo.Substring(1, 7);
            ddlNationality.Nationality = _libertycarmoredetailCheck.Nationality;
            txtEmpName.Text = _libertycarmoredetailCheck.EmpNameandTrade;

            ddlDrivetowestmalaysia.SelectedValue = _libertycarmoredetailCheck.HasDriveWestMalaysia;
            ddlNCDReason.SelectedValue = _libertycarmoredetailCheck.NCDReason;
            txtNCDReason.Text = _libertycarmoredetailCheck.NCDReason;

            txtVehicleNo.Text = _libertycarmoredetailCheck.VechicleNo;
            ddlDORegisteration.Day = _libertycarmoredetailCheck.DateofRegistration.Day;
            ddlDORegisteration.Month = _libertycarmoredetailCheck.DateofRegistration.Month;
            ddlDORegisteration.Year = _libertycarmoredetailCheck.DateofRegistration.Year;

            txtEngineNo.Text = _libertycarmoredetailCheck.EngineNo;
            txtChassisNo.Text = _libertycarmoredetailCheck.ChassisNo;

            if (_libertycarmoredetailCheck.HasHirePurchase)
            {
                rdoYesHirePurchase.Checked = true;
                ddlHirePurchaseCompany.Text = _libertycarmoredetailCheck.HPCompanyName;
            }
            else
            {
                rdoYesHirePurchase.Checked = false;
                ddlHirePurchaseCompany.Text = "";
            }

            ddlCurInsuranceCompany.Text = _libertycarmoredetailCheck.PreInsurerName;

            if (ddlCurInsuranceCompany.Text != "177")
            {
                txtInsVehicleNo.Text = _libertycarmoredetailCheck.PreInsVechicleNo;
                ddlDOCancellation.Day = _libertycarmoredetailCheck.PreInsExpiryDate.Day;
                ddlDOCancellation.Month = _libertycarmoredetailCheck.PreInsExpiryDate.Month;
                ddlDOCancellation.Year = _libertycarmoredetailCheck.PreInsExpiryDate.Year;
                lblNCDvalue.Text = _libertycarmoredetailCheck.NCDEntitlement;
            }

            if (_libertycarmoredetailCheck.HasVechicleModified)
            {
                rdoYesVechicleModification.Checked = true;
                txtVMReason.Text = _libertycarmoredetailCheck.VechicleModifyReason;
            }
            else
            {
                rdoYesVechicleModification.Checked = false;
                txtVMReason.Text = "";
            }

            if (_libertycarmoredetailCheck.HasAccessory)
            {
                rdoYesAccessories.Checked = true;
                txtAccessories.Text = _libertycarmoredetailCheck.AccessoryDescription;
            }
            else
            {
                rdoYesAccessories.Checked = false;
                txtAccessories.Text = "";
            }

            if (_libertycarmoredetailCheck.HasConvictedMoterOffence)
            {
                rdoYesConvicted.Checked = true;
                txtConvictedReason.Text = _libertycarmoredetailCheck.ConvictedReason;
            }
            else
            {
                rdoYesConvicted.Checked = false;
                txtConvictedReason.Text = "";
            }

            if (_libertycarmoredetailCheck.HasDemeritPoints)
            {
                rdoYesDermeritPoints.Checked = true;
            }
            else
            {
                rdoYesDermeritPoints.Checked = false;
            }

            if (_libertycarmoredetailCheck.HasPhysicalImpairment)
            {
                rdoYesPhysicalimpairment.Checked = true;
                txtPIReason.Text = _libertycarmoredetailCheck.PhysicalImpairmentReason;
            }
            else
            {
                rdoYesPhysicalimpairment.Checked = false;
                txtPIReason.Text = "";
            }

            if (_libertycarmoredetailCheck.HasInsuranceTerminated)
            {
                rdoYesInsuranceterminated.Checked = true;
                txtITReason.Text = _libertycarmoredetailCheck.InsuranceTerminatedReason;
            }
            else
            {
                rdoYesInsuranceterminated.Checked = false;
                txtITReason.Text = "";
            }

            if (_libertycarmoredetailCheck.Info1 == "1")
            {
                rdoYesRefused.Checked = true;
                txtRefusedReason.Text = _libertycarmoredetailCheck.Info2;
            }
            else
            {
                rdoYesRefused.Checked = false;
                txtRefusedReason.Text = "";
            }

            if (_libertycarmoredetailCheck.Info3 == "1")
            {
                rdoYes.Checked = true;
            }
            else
            {
                rdoYes.Checked = false;
            }

        }

    }

    protected void ibtnBack_Click(object sender, ImageClickEventArgs e)
    {
        //Response.Redirect("~/car-insurance/results.aspx?sortby=0");
        Response.Redirect("~/car-insurance/your-request.aspx");
    }

    protected void imgbtnBackTop_Click(object sender, ImageClickEventArgs e)
    {
        if (Session["FromSummary"] != null)
        {
            if (Session["FromSummary"].ToString().Trim() == "1")
            {
                Response.Redirect("~/car-insurance/results-new.aspx");
            }
            else
            {
                Response.Redirect("~/car-insurance/results-details.aspx");
            }
        }
        else
        {
            Response.Redirect("~/car-insurance/results-new.aspx");
        }
    }

    protected void ibtPostCode_Click(object sender, ImageClickEventArgs e)
    {
        GetPostCode();
    }

    private void GetPostCode()
    {
        rfvPostCode.Validate();
        revPostCode.Validate();
        if (rfvPostCode.IsValid && revPostCode.IsValid)
        {
            txtPostCode.ControlStyle.CssClass = "";
            txtAddress.ControlStyle.CssClass = "";
            MyLocation _myLoc = new MyLocation();
            //string _strAddress = _myLoc.GetAddressByPostCode(txtPostCode.Text);
            //if (_strAddress != null && _strAddress != string.Empty)
            //{
            //    if (_strAddress.ToLower().Contains("invalid api"))
            //    {
            //        txtAddress.Text = "Address can't be retrieved. Please type your address detail here.";
            //    }
            //    else
            //    {
            //        txtAddress.Text = _strAddress;
            //    }
            //}
            //else
            //{
            //    txtAddress.Text = "Address is not found.";
            //}

            System.Data.DataSet _ds = _myLoc.GetAddressByPostCodeDataSet(txtPostCode.Text);
            ddlAddressList.Items.Clear();
            string _lstValue;
            string _lstText;
            int _rowCount = 0;

            if (_ds != null)
            {
                if (_ds.Tables.Count > 0)
                {
                    foreach (System.Data.DataTable _dt in _ds.Tables)
                    {
                        if (_dt.Rows.Count > 0 && _dt.Columns.Count >= 2)
                        {
                            foreach (System.Data.DataRow _dr in _dt.Rows)
                            {
                                //lblAddress2.Text += _dr["t"].ToString() + "<br />";
                                //lblAddress2.Text += _dr["a"].ToString() + "<br /><br />";

                                if (_dr["t"] != null && _dr["a"] != null)
                                {
                                    _lstValue = _dr["t"].ToString() + ", " + _dr["a"].ToString();
                                    _lstText = _dr["t"].ToString();
                                    ddlAddressList.Items.Add(new ListItem(_lstText, _lstValue));
                                    if (_rowCount == 0)
                                    {
                                        txtAddress.Text = _lstValue;
                                        //ibtPostCode.Enabled = false;
                                        txtAddress.ReadOnly = true;
                                    }

                                    _rowCount++;
                                }
                            }
                        }
                        else
                        {
                            txtAddress.Text = "Confirm postcode or enter manually.";
                            txtAddress.ReadOnly = false;
                            txtAddress.ControlStyle.CssClass = "validationError";
                        }
                    }
                }
                else
                {
                    txtAddress.Text = "Confirm postcode or enter manually.";
                    txtAddress.ReadOnly = false;
                    txtAddress.ControlStyle.CssClass = "validationError";
                }
            }
            else
            {
                txtAddress.Text = "Please type your address here.";
                txtAddress.ReadOnly = false;
                txtAddress.ControlStyle.CssClass = "validationError";
            }

            if (_rowCount > 1)
            {
                divAddressList.Visible = true;
            }
            else
            {
                divAddressList.Visible = false;

            }
        }
        else
        {
            txtPostCode.ControlStyle.CssClass = "validationError";
            ddlAddressList.Items.Clear();
            divAddressList.Visible = false;
            txtAddress.Text = "Invalid postcode.";
            txtAddress.ControlStyle.CssClass = "validationError";
        }
    }

    protected void txtPostCode_TextChanged(object sender, EventArgs e)
    {
        GetPostCode();
    }

    protected void ddlAddressList_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (ddlAddressList.Items.Count > 0 && ddlAddressList.SelectedIndex >= 0)
        {
            txtAddress.Text = ddlAddressList.Text;
        }
    }

    protected void btnPostCode_Click(object sender, EventArgs e)
    {
        //txtAddress.Text = "";
        ////ChangeValidationEffectServerSide("maincardholder");
        //PostCode _postcode = new PostCode();
        //_postcode = GetPostCode(txtPostCode.Text);
        //if (_postcode != null)
        //{
        //    if (_postcode.BuildingName.Trim() != string.Empty)
        //    {
        //        txtAddress.Text += _postcode.BuildingName + ", ";
        //    }

        //    if (_postcode.StreetName.Trim() != string.Empty)
        //    {
        //        txtAddress.Text += _postcode.StreetName;
        //    }
        //}
        //else
        //{
        //    txtAddress.Text = "No Address Found.";
        //}
        //_postcode = null;

        txtPostCode_TextChanged(sender, e);
    }

    //protected void btnHPostCode_Click(object sender, EventArgs e)
    //{
    //    txtHAddress.Text = "";
    //    PostCode _postcode = new PostCode();
    //    _postcode = GetPostCode(txtHPostCode.Text);
    //    if (_postcode != null)
    //    {
    //        if (_postcode.BuildingName.Trim() != string.Empty)
    //        {
    //            txtHAddress.Text += _postcode.BuildingName + ", ";
    //        }

    //        if (_postcode.StreetName.Trim() != string.Empty)
    //        {
    //            txtHAddress.Text += _postcode.StreetName;
    //        }
    //    }
    //    else
    //    {
    //        txtHAddress.Text = "No Address Found.";
    //    }
    //    _postcode = null;
    //}

    public void LoadCarPolicyDetails()
    {
        if (Request.Params["uid"] != null && Request.Params["guid"] != null && Request.Params["carid"] != null
            && Request.Params["customerid"] != null && Request.Params["carresultid"] != null && Request.Params["providercompanyid"] != null)
        {
            _CarId = Convert.ToInt64(lblCarId.Text);
            _UserId = Convert.ToInt64(lblCustomerId.Text);
            _CXCTypeId = Convert.ToInt64(lblCarResultId.Text);
            _ProviderId = Convert.ToInt64(lblProviderCompanyId.Text);
        }
        else
        {
            _CarId = Convert.ToInt64(Session[General.CarId].ToString());
            _UserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
            _CXCTypeId = Convert.ToInt64(Session[CE.Global.General.CarResultId].ToString());
            _ProviderId = Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString());
        }
        //DataTable _dtProvider = new DataTable();
        DataSet _dtProvider = new DataSet();
        LibertyCarMoreDetail _libertycarmoredetail = new LibertyCarMoreDetail();
        LibertyCarMoreDetailDB _libertycarmoredetaildb = new LibertyCarMoreDetailDB();
        _dtProvider = _libertycarmoredetaildb.GetCarPolicyDetails(_CarId, _UserId, _CXCTypeId, _ProviderId);
        if (_dtProvider != null)
        {
            if (_dtProvider.Tables[0].Rows.Count > 0 && _dtProvider.Tables[1].Rows.Count > 0 && _dtProvider.Tables[2].Rows.Count > 0)
            {
                //lblProvider.Text = _dtProvider.Rows[0]["CompanyName"].ToString();
                //lblPremium.Text = "$ " + _dtProvider.Rows[0]["AnnualPremium"].ToString();
                //lblPackage.Text = _dtProvider.Rows[0]["PlanName"].ToString();
                //lblPackageHead.Visible = true;
                //lblPremiumHead.Visible = true;
                lblYrofManufacture.Text = _dtProvider.Tables[0].Rows[0]["ManufactYear"].ToString();
                lblYrofRegister.Text = _dtProvider.Tables[0].Rows[0]["RegYear"].ToString();
                ddlDORegisteration.StartYear = Convert.ToInt32(_dtProvider.Tables[0].Rows[0]["RegYear"].ToString());
                ddlDORegisteration.EndYear = Convert.ToInt32(_dtProvider.Tables[0].Rows[0]["RegYear"].ToString());
                lblCarMakemodel.Text = _dtProvider.Tables[0].Rows[0]["MakeModelDesc"].ToString();
                lblOffpeakvehile.Text = _dtProvider.Tables[0].Rows[0]["Offbeak"].ToString();
                if (_dtProvider.Tables[0].Rows[0]["AppNCD"].ToString() == "-1")
                {
                    lblNCDvalue.Text = "No NCD (First Policy)";
                }
                else
                {
                    lblNCDvalue.Text = _dtProvider.Tables[0].Rows[0]["AppNCD"].ToString() + "%";
                }

                inputNCD.Value = _dtProvider.Tables[0].Rows[0]["AppNCD"].ToString();
                lblNCDRenewal.Text = _dtProvider.Tables[0].Rows[0]["AppNCD"].ToString() + "%";

                lblAnyclaim.Text = _dtProvider.Tables[0].Rows[0]["Claim"].ToString();
                inputClaim.Value = _dtProvider.Tables[0].Rows[0]["Claim"].ToString();

                lblOffenceDriving.Text = _dtProvider.Tables[0].Rows[0]["OffDriveCom"].ToString();
                if (_dtProvider.Tables[0].Rows[0]["AddDriver"].ToString() == "Yes")
                {
                    lblAddDriver.Text = _dtProvider.Tables[0].Rows[0]["NoOfDriver"].ToString();
                    txtDriverCount.Text = _dtProvider.Tables[0].Rows[0]["NoOfDriver"].ToString();
                }
                else
                {
                    lblAddDriver.Text = _dtProvider.Tables[0].Rows[0]["AddDriver"].ToString();
                    txtDriverCount.Text = "0";
                }
                EnableDriverPanels();
                lblCommencementdate.Text = _dtProvider.Tables[0].Rows[0]["CommenceDate"].ToString();
                lblSelectInsurer.Text = _dtProvider.Tables[1].Rows[0]["CompanyName"].ToString();

                //Sakthi on 30 Nov 2011 -- Start
                Int32 _PromoValue = Convert.ToInt32(_dtProvider.Tables[1].Rows[0]["PetrolVoucher"].ToString());
                if (_PromoValue == 100)
                {
                    divPromoVoucher.Visible = true;
                    imgPromoAdd1.Visible = true;
                    imgPromoAdd2.Visible = false;
                }
                else if (_PromoValue == 50)
                {
                    divPromoVoucher.Visible = true;
                    imgPromoAdd1.Visible = false;
                    imgPromoAdd2.Visible = true;
                }
                else
                {
                    divPromoVoucher.Visible = false;
                    imgPromoAdd1.Visible = false;
                    imgPromoAdd2.Visible = false;
                }
                //Sakthi on 30 Nov 2011 -- Else

                double _annualPremium = Convert.ToDouble(_dtProvider.Tables[1].Rows[0]["AnnualPremium"].ToString());
                double _monthlyPremium = _annualPremium / 12;
                _monthlyPremium = Math.Ceiling(_monthlyPremium);
                double _monthlyPremium6Months = _annualPremium / 6;
                _monthlyPremium6Months = Math.Ceiling(_monthlyPremium6Months);
                //lblPremiums.Text = "$" + _dtProvider.Tables[1].Rows[0]["AnnualPremium"].ToString() + " (" + String.Format("${0:0,0.00}", _monthlyPremium) + " per month)";
                lblPremiums.Text = "$" + _dtProvider.Tables[1].Rows[0]["AnnualPremium"].ToString() + "<br><small>6 months : " + String.Format("${0:0,0}", _monthlyPremium6Months) + " per month</small><br><small>12 months : " + String.Format("${0:0,0}", _monthlyPremium) + " per month</small>";
                lblWorkshopPlan.Text = _dtProvider.Tables[1].Rows[0]["PlanName"].ToString();
                string convertno = General.GetRefNumber(_CarId);
                if (_ProviderId == 23)
                {
                    lblQRefNo.Text = "H" + convertno.ToString();
                }
                else if (_ProviderId == 29)
                {
                    lblQRefNo.Text = "L" + convertno.ToString();
                }
                else if (_ProviderId == 30)
                {
                    lblQRefNo.Text = "E" + convertno.ToString();
                }
            }
            else
            {
                //Response.Redirect("~/user/usermessage.aspx?errorcode=CI502");
                Response.Redirect("~/user/usermessage.aspx?mt=CI&ec=502");
            }
        }
        else
        {
            //Response.Redirect("~/user/usermessage.aspx?errorcode=CI502");
            Response.Redirect("~/user/usermessage.aspx?mt=CI&ec=502");
        }
        //else
        //{
        //    lblProvider.Text = "";
        //    lblPremium.Text = "";
        //    lblPackage.Text = "";
        //    lblPackageHead.Visible = false;
        //    lblPremiumHead.Visible = false;
        //}
        ddlCurInsuranceCompany.Text = _dtProvider.Tables[0].Rows[0]["Info1"].ToString();
        LoadCarDrivers();
    }

    private void LoadCarDrivers()
    {
        CarDriverDB _cardriverdb = new CarDriverDB();
        if (Request.Params["uid"] != null && Request.Params["guid"] != null && Request.Params["carid"] != null
            && Request.Params["customerid"] != null && Request.Params["carresultid"] != null && Request.Params["providercompanyid"] != null)
        {
            _CarId = Convert.ToInt64(lblCarId.Text);
            _UserId = Convert.ToInt64(lblCustomerId.Text);
        }
        else
        {
            _CarId = Convert.ToInt64(Session[General.CarId].ToString());
            _UserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
        }

        DataTable _driverList = _cardriverdb.GetDriverList(_CarId, _UserId);
        if (_driverList.Rows.Count > 0)
        {
            lblDriverId1.Text = _driverList.Rows[0]["CarDriverId"].ToString();

            _dtDOB1 = Convert.ToDateTime(_driverList.Rows[0]["DOB"].ToString());
            lblDriverDOB1.Text = _dtDOB1.Day.ToString("00") + "/" + _dtDOB1.Month.ToString("00") + "/" + _dtDOB1.Year.ToString("0000");
            ddlDriverGender1.Gender = _driverList.Rows[0]["Gender"].ToString();
            if (_driverList.Rows[0]["Gender"].ToString() == "M")
            {
                lblDriverGender1.Text = "Male";
            }
            else if (_driverList.Rows[0]["Gender"].ToString() == "F")
            {
                lblDriverGender1.Text = "Female";
            }
            if (_driverList.Rows[0]["Salutation"].ToString() != null && _driverList.Rows[0]["Salutation"].ToString() != "")
            {
                ddlDriverSalutation1.Saluation = _driverList.Rows[0]["Salutation"].ToString();
            }
            if (_driverList.Rows[0]["Surname"].ToString() != null && _driverList.Rows[0]["Surname"].ToString() != "")
            {
                txtDriverSurName1.Text = _driverList.Rows[0]["Surname"].ToString();
            }
            if (_driverList.Rows[0]["GivenName"].ToString() != null && _driverList.Rows[0]["GivenName"].ToString() != "")
            {
                txtDriverGivenName1.Text = _driverList.Rows[0]["GivenName"].ToString();
            }
            if (_driverList.Rows[0]["IDType"].ToString() != null && _driverList.Rows[0]["IDType"].ToString() != "")
            {
                ddlDriverIdType1.IdType = _driverList.Rows[0]["IDType"].ToString();
            }
            if (_driverList.Rows[0]["IDNo"].ToString() != null && _driverList.Rows[0]["IDNo"].ToString() != "")
            {
                ddlDriverIdNumber1.Prefix = _driverList.Rows[0]["IDNo"].ToString().Substring(0, 1);
                ddlDriverIdNumber1.Postfix = _driverList.Rows[0]["IDNo"].ToString().Substring(8, 1);
                ddlDriverIdNumber1.IDNumber = _driverList.Rows[0]["IDNo"].ToString().Substring(1, 7);
            }
        }
        if (_driverList.Rows.Count > 1)
        {
            lblDriverId2.Text = _driverList.Rows[1]["CarDriverId"].ToString();

            _dtDOB2 = Convert.ToDateTime(_driverList.Rows[1]["DOB"].ToString());
            lblDriverDOB2.Text = _dtDOB2.Day.ToString("00") + "/" + _dtDOB2.Month.ToString("00") + "/" + _dtDOB2.Year.ToString("0000");
            ddlDriverGender2.Gender = _driverList.Rows[1]["Gender"].ToString();
            if (_driverList.Rows[1]["Gender"].ToString() == "M")
            {
                lblDriverGender2.Text = "Male";
            }
            else if (_driverList.Rows[1]["Gender"].ToString() == "F")
            {
                lblDriverGender2.Text = "Female";
            }
            if (_driverList.Rows[1]["Salutation"].ToString() != null && _driverList.Rows[1]["Salutation"].ToString() != "")
            {
                ddlDriverSalutation2.Saluation = _driverList.Rows[1]["Salutation"].ToString();
            }
            if (_driverList.Rows[1]["Surname"].ToString() != null && _driverList.Rows[1]["Surname"].ToString() != "")
            {
                txtDriverSurName2.Text = _driverList.Rows[1]["Surname"].ToString();
            }
            if (_driverList.Rows[1]["GivenName"].ToString() != null && _driverList.Rows[1]["GivenName"].ToString() != "")
            {
                txtDriverGivenName2.Text = _driverList.Rows[1]["GivenName"].ToString();
            }
            if (_driverList.Rows[1]["IDType"].ToString() != null && _driverList.Rows[1]["IDType"].ToString() != "")
            {
                ddlDriverIdType2.IdType = _driverList.Rows[1]["IDType"].ToString();
            }
            if (_driverList.Rows[1]["IDNo"].ToString() != null && _driverList.Rows[1]["IDNo"].ToString() != "")
            {
                ddlDriverIdNumber2.Prefix = _driverList.Rows[1]["IDNo"].ToString().Substring(0, 1);
                ddlDriverIdNumber2.Postfix = _driverList.Rows[1]["IDNo"].ToString().Substring(8, 1);
                ddlDriverIdNumber2.IDNumber = _driverList.Rows[1]["IDNo"].ToString().Substring(1, 7);
            }
        }
        if (_driverList.Rows.Count > 2)
        {
            lblDriverId3.Text = _driverList.Rows[2]["CarDriverId"].ToString();

            _dtDOB3 = Convert.ToDateTime(_driverList.Rows[2]["DOB"].ToString());
            lblDriverDOB3.Text = _dtDOB3.Day.ToString("00") + "/" + _dtDOB3.Month.ToString("00") + "/" + _dtDOB3.Year.ToString("0000");
            ddlDriverGender3.Gender = _driverList.Rows[2]["Gender"].ToString();
            if (_driverList.Rows[2]["Gender"].ToString() == "M")
            {
                lblDriverGender3.Text = "Male";
            }
            else if (_driverList.Rows[2]["Gender"].ToString() == "F")
            {
                lblDriverGender3.Text = "Female";
            }
            if (_driverList.Rows[2]["Salutation"].ToString() != null && _driverList.Rows[2]["Salutation"].ToString() != "")
            {
                ddlDriverSalutation3.Saluation = _driverList.Rows[0]["Salutation"].ToString();
            }
            if (_driverList.Rows[2]["Salutation"].ToString() != null && _driverList.Rows[2]["Salutation"].ToString() != "")
            {
                ddlDriverSalutation3.Saluation = _driverList.Rows[2]["Salutation"].ToString();
            }
            if (_driverList.Rows[2]["Surname"].ToString() != null && _driverList.Rows[2]["Surname"].ToString() != "")
            {
                txtDriverSurName3.Text = _driverList.Rows[2]["Surname"].ToString();
            }
            if (_driverList.Rows[2]["GivenName"].ToString() != null && _driverList.Rows[2]["GivenName"].ToString() != "")
            {
                txtDriverGivenName3.Text = _driverList.Rows[2]["GivenName"].ToString();
            }
            if (_driverList.Rows[2]["IDType"].ToString() != null && _driverList.Rows[2]["IDType"].ToString() != "")
            {
                ddlDriverIdType3.IdType = _driverList.Rows[2]["IDType"].ToString();
            }
            if (_driverList.Rows[2]["IDNo"].ToString() != null && _driverList.Rows[2]["IDNo"].ToString() != "")
            {
                ddlDriverIdNumber3.Prefix = _driverList.Rows[2]["IDNo"].ToString().Substring(0, 1);
                ddlDriverIdNumber3.Postfix = _driverList.Rows[2]["IDNo"].ToString().Substring(8, 1);
                ddlDriverIdNumber3.IDNumber = _driverList.Rows[2]["IDNo"].ToString().Substring(1, 7);
            }
        }
        if (_driverList.Rows.Count > 3)
        {
            lblDriverId4.Text = _driverList.Rows[3]["CarDriverId"].ToString();

            _dtDOB4 = Convert.ToDateTime(_driverList.Rows[3]["DOB"].ToString());
            lblDriverDOB4.Text = _dtDOB4.Day.ToString("00") + "/" + _dtDOB4.Month.ToString("00") + "/" + _dtDOB4.Year.ToString("0000");
            ddlDriverGender4.Gender = _driverList.Rows[3]["Gender"].ToString();
            if (_driverList.Rows[3]["Gender"].ToString() == "M")
            {
                lblDriverGender4.Text = "Male";
            }
            else if (_driverList.Rows[3]["Gender"].ToString() == "F")
            {
                lblDriverGender4.Text = "Female";
            }
            if (_driverList.Rows[3]["Salutation"].ToString() != null && _driverList.Rows[3]["Salutation"].ToString() != "")
            {
                ddlDriverSalutation4.Saluation = _driverList.Rows[3]["Salutation"].ToString();
            }
            if (_driverList.Rows[3]["Surname"].ToString() != null && _driverList.Rows[3]["Surname"].ToString() != "")
            {
                txtDriverSurName4.Text = _driverList.Rows[3]["Surname"].ToString();
            }
            if (_driverList.Rows[3]["GivenName"].ToString() != null && _driverList.Rows[3]["GivenName"].ToString() != "")
            {
                txtDriverGivenName4.Text = _driverList.Rows[3]["GivenName"].ToString();
            }
            if (_driverList.Rows[3]["IDType"].ToString() != null && _driverList.Rows[3]["IDType"].ToString() != "")
            {
                ddlDriverIdType4.IdType = _driverList.Rows[3]["IDType"].ToString();
            }
            if (_driverList.Rows[3]["IDNo"].ToString() != null && _driverList.Rows[3]["IDNo"].ToString() != "")
            {
                ddlDriverIdNumber4.Prefix = _driverList.Rows[3]["IDNo"].ToString().Substring(0, 1);
                ddlDriverIdNumber4.Postfix = _driverList.Rows[3]["IDNo"].ToString().Substring(8, 1);
                ddlDriverIdNumber4.IDNumber = _driverList.Rows[3]["IDNo"].ToString().Substring(1, 7);
            }
        }
        if (_driverList.Rows.Count > 4)
        {
            lblDriverId5.Text = _driverList.Rows[4]["CarDriverId"].ToString();

            _dtDOB5 = Convert.ToDateTime(_driverList.Rows[4]["DOB"].ToString());
            lblDriverDOB5.Text = _dtDOB5.Day.ToString("00") + "/" + _dtDOB5.Month.ToString("00") + "/" + _dtDOB5.Year.ToString("0000");
            ddlDriverGender5.Gender = _driverList.Rows[4]["Gender"].ToString();
            if (_driverList.Rows[4]["Gender"].ToString() == "M")
            {
                lblDriverGender5.Text = "Male";
            }
            else if (_driverList.Rows[4]["Gender"].ToString() == "F")
            {
                lblDriverGender5.Text = "Female";
            }
            if (_driverList.Rows[4]["Salutation"].ToString() != null && _driverList.Rows[4]["Salutation"].ToString() != "")
            {
                ddlDriverSalutation5.Saluation = _driverList.Rows[4]["Salutation"].ToString();
            }
            if (_driverList.Rows[4]["Surname"].ToString() != null && _driverList.Rows[4]["Surname"].ToString() != "")
            {
                txtDriverSurName5.Text = _driverList.Rows[4]["Surname"].ToString();
            }
            if (_driverList.Rows[4]["GivenName"].ToString() != null && _driverList.Rows[4]["GivenName"].ToString() != "")
            {
                txtDriverGivenName5.Text = _driverList.Rows[4]["GivenName"].ToString();
            }
            if (_driverList.Rows[4]["IDType"].ToString() != null && _driverList.Rows[4]["IDType"].ToString() != "")
            {
                ddlDriverIdType5.IdType = _driverList.Rows[4]["IDType"].ToString();
            }
            if (_driverList.Rows[4]["IDNo"].ToString() != null && _driverList.Rows[4]["IDNo"].ToString() != "")
            {
                ddlDriverIdNumber5.Prefix = _driverList.Rows[4]["IDNo"].ToString().Substring(0, 1);
                ddlDriverIdNumber5.Postfix = _driverList.Rows[4]["IDNo"].ToString().Substring(8, 1);
                ddlDriverIdNumber5.IDNumber = _driverList.Rows[4]["IDNo"].ToString().Substring(1, 7);
            }
        }
    }

    private void CheckValidation()
    {
        txtName.Text = General.ClearScriptTag(txtName.Text);
        txtPostCode.Text = General.ClearScriptTag(txtPostCode.Text);
        txtUnit1.Text = General.ClearScriptTag(txtUnit1.Text);
        txtUnit2.Text = General.ClearScriptTag(txtUnit2.Text);
        txtAccess.Text = General.ClearScriptTag(txtAccess.Text);
        txtVehicleNo.Text = General.ClearScriptTag(txtVehicleNo.Text);
        //txtOdometerReading.Text = General.ClearScriptTag(txtOdometerReading.Text);
        txtEngineNo.Text = General.ClearScriptTag(txtEngineNo.Text);
        txtChassisNo.Text = General.ClearScriptTag(txtChassisNo.Text);
        //txtEstimateMarketValue.Text = General.ClearScriptTag(txtEstimateMarketValue.Text);
        //txtHirePurchaseCompany.Text = General.ClearScriptTag(txtHirePurchaseCompany.Text);
        //txtHPostCode.Text = General.ClearScriptTag(txtHPostCode.Text);
        //txtHUnit1.Text = General.ClearScriptTag(txtHUnit1.Text);
        //txtHUnit2.Text = General.ClearScriptTag(txtHUnit2.Text);
        //txtHAddress.Text = General.ClearScriptTag(txtHAddress.Text);
        txtInsVehicleNo.Text = General.ClearScriptTag(txtInsVehicleNo.Text);
        //txtInsPolicyNo.Text = General.ClearScriptTag(txtInsPolicyNo.Text);
        txtVMReason.Text = General.ClearScriptTag(txtVMReason.Text);
        txtAccessories.Text = General.ClearScriptTag(txtAccessories.Text);
        txtConvictedReason.Text = General.ClearScriptTag(txtConvictedReason.Text);
        txtPIReason.Text = General.ClearScriptTag(txtPIReason.Text);
        txtITReason.Text = General.ClearScriptTag(txtITReason.Text);
        txtRefusedReason.Text = General.ClearScriptTag(txtRefusedReason.Text);

        #region Hire Purchase
        if (rdoYesHirePurchase.Checked)
        {
            rfvHirePurchaseCompany.Enabled = true;
            //rfvHPostCode.Enabled = true;
            //revHPostCode.Enabled = true;
            //rfvHUnit1.Enabled = true;
            //rfvHUnit2.Enabled = true;
            //rfvHAddress.Enabled = true;
            //rfvHirePurchase.Enabled = false;
        }
        else
        {
            rfvHirePurchaseCompany.Enabled = false;
            //rfvHPostCode.Enabled = false;
            //revHPostCode.Enabled = false;
            //rfvHUnit1.Enabled = false;
            //rfvHUnit2.Enabled = false;
            //rfvHAddress.Enabled = false;
            //rfvHirePurchase.Enabled = false;
        }
        #endregion

        #region Pre Insurance
        //if (rdoYesOtherInsurence.Checked)
        if (ddlCurInsuranceCompany.Text != "177")
        {
            rfvCurInsuranceCompany.Enabled = true;
            rfvInsVehicleNo.Enabled = true;
            //rfvInsPolicyNo.Enabled = true;
            ddlDOCancellation.IsEnableValidation(true);
            //rfvNCD.Enabled = true;
            //rfvOI.Enabled = false;
        }
        else
        {
            rfvCurInsuranceCompany.Enabled = true;
            rfvInsVehicleNo.Enabled = false;
            //rfvInsPolicyNo.Enabled = false;
            ddlDOCancellation.IsEnableValidation(false);
            //rfvNCD.Enabled = false;
            //rfvOI.Enabled = false;
        }
        #endregion

        #region Vechicle Modified
        if (rdoYesVechicleModification.Checked)
        {
            rfvVMReason.Enabled = true;
            //rfvVechicleModification.Enabled = false;
        }
        else
        {
            rfvVMReason.Enabled = false;
            //rfvVechicleModification.Enabled = false;
        }
        #endregion

        #region Accessary
        if (rdoYesAccessories.Checked)
        {
            rfvAccessories.Enabled = true;
            //rfvAccess.Enabled = false;
        }
        else
        {
            rfvAccessories.Enabled = false;
            //rfvAccess.Enabled = false;
        }
        #endregion

        #region Convicted
        if (rdoYesConvicted.Checked)
        {
            rfvConvictedReason.Enabled = true;
            //rfvConvicted.Enabled = false;
        }
        else
        {
            rfvConvictedReason.Enabled = false;
            //rfvConvicted.Enabled = false;
        }
        #endregion

        #region NCD

        if (ddlNCDReason.SelectedItem.Text == "Others")
        {
            rfvNCDReason.Enabled = true;
        }
        else
        {
            rfvNCDReason.Enabled = false;
        }
        #endregion

        #region Demerit Points
        if (rdoYesDermeritPoints.Checked)
        {
            rfvDrivername1.Enabled = true;
            rfvTotalpoints1.Enabled = true;
            ddlDODemerit1.IsEnableValidation(true);
            rfvOffencetype1.Enabled = true;
            //rfvDermeritPoints.Enabled = false;

            if (txtDrivername2.Text != string.Empty && txtTotalpoints2.Text != string.Empty && txtOffencetype2.Text != string.Empty)
            {
                ddlDODemerit2.IsEnableValidation(true);
            }
            else
            {
                ddlDODemerit2.IsEnableValidation(false);
            }
            if (txtDrivername3.Text != string.Empty && txtTotalpoints3.Text != string.Empty && txtOffencetype3.Text != string.Empty)
            {
                ddlDODemerit3.IsEnableValidation(true);
            }
            else
            {
                ddlDODemerit3.IsEnableValidation(false);
            }
            if (txtDrivername4.Text != string.Empty && txtTotalpoints4.Text != string.Empty && txtOffencetype4.Text != string.Empty)
            {
                ddlDODemerit4.IsEnableValidation(true);
            }
            else
            {
                ddlDODemerit4.IsEnableValidation(false);
            }
            if (txtDrivername5.Text != string.Empty && txtTotalpoints5.Text != string.Empty && txtOffencetype5.Text != string.Empty)
            {
                ddlDODemerit5.IsEnableValidation(true);
            }
            else
            {
                ddlDODemerit5.IsEnableValidation(false);
            }
            if (txtDrivername6.Text != string.Empty && txtTotalpoints6.Text != string.Empty && txtOffencetype6.Text != string.Empty)
            {
                ddlDODemerit6.IsEnableValidation(true);
            }
            else
            {
                ddlDODemerit6.IsEnableValidation(false);
            }
        }
        else
        {
            rfvDrivername1.Enabled = false;
            rfvTotalpoints1.Enabled = false;
            ddlDODemerit1.IsEnableValidation(false);
            rfvOffencetype1.Enabled = false;
            ddlDODemerit2.IsEnableValidation(false);
            ddlDODemerit3.IsEnableValidation(false);
            ddlDODemerit4.IsEnableValidation(false);
            ddlDODemerit5.IsEnableValidation(false);
            ddlDODemerit6.IsEnableValidation(false);
            //rfvDermeritPoints.Enabled = false;
        }
        #endregion

        #region Physical Impairment
        if (rdoYesPhysicalimpairment.Checked)
        {
            rfvPIReason.Enabled = true;
            //rfvPhysicalimpairment.Enabled = false;
        }
        else
        {
            rfvPIReason.Enabled = false;
            //rfvPhysicalimpairment.Enabled = false;
        }
        #endregion

        #region Insurance Terminated
        if (rdoYesInsuranceterminated.Checked)
        {
            rfvITReason.Enabled = true;
            //rfvInsuranceterminated.Enabled = false;
        }
        else
        {
            rfvITReason.Enabled = false;
            //rfvInsuranceterminated.Enabled = false;
        }
        #endregion

        #region Insurance Refused
        if (rdoYesRefused.Checked)
        {
            rfvRefusedReason.Enabled = true;
        }
        else
        {
            rfvRefusedReason.Enabled = false;
        }
        #endregion

        #region Payment
        if (rdoCreditCard.Checked)
        {
            rfvNameoftheCard.Enabled = true;
            rfvIssuingBank.Enabled = true;
            rfvCardNo1.Enabled = true;
            revCardNo1.Enabled = true;
            rfvCardNo2.Enabled = true;
            revCardNo2.Enabled = true;
            rfvCardNo3.Enabled = true;
            revCardNo3.Enabled = true;
            rfvCardNo4.Enabled = true;
            revCardNo4.Enabled = true;
            csvCreditCardValid.Enabled = true;
            rfvCardExpiryMonth.Enabled = true;
            rfvCardExpiryYear.Enabled = true;
            csvCCExpiredValid.Enabled = true;
            rfvCardType.Enabled = true;
        }
        else if (rdoCash.Checked)
        {
            rfvNameoftheCard.Enabled = false;
            rfvIssuingBank.Enabled = false;
            rfvCardNo1.Enabled = false;
            revCardNo1.Enabled = false;
            rfvCardNo2.Enabled = false;
            revCardNo2.Enabled = false;
            rfvCardNo3.Enabled = false;
            revCardNo3.Enabled = false;
            rfvCardNo4.Enabled = false;
            revCardNo4.Enabled = false;
            csvCreditCardValid.Enabled = false;
            rfvCardExpiryMonth.Enabled = false;
            rfvCardExpiryYear.Enabled = false;
            csvCCExpiredValid.Enabled = false;
            rfvCardType.Enabled = false;
        }
        #endregion
    }

    private void CheckValidationSave()
    {
        txtName.Text = General.ClearScriptTag(txtName.Text);
        txtPostCode.Text = General.ClearScriptTag(txtPostCode.Text);
        txtUnit1.Text = General.ClearScriptTag(txtUnit1.Text);
        txtUnit2.Text = General.ClearScriptTag(txtUnit2.Text);
        txtAccess.Text = General.ClearScriptTag(txtAccess.Text);
        txtVehicleNo.Text = General.ClearScriptTag(txtVehicleNo.Text);
        txtEngineNo.Text = General.ClearScriptTag(txtEngineNo.Text);
        txtChassisNo.Text = General.ClearScriptTag(txtChassisNo.Text);
        txtInsVehicleNo.Text = General.ClearScriptTag(txtInsVehicleNo.Text);
        txtVMReason.Text = General.ClearScriptTag(txtVMReason.Text);
        txtAccessories.Text = General.ClearScriptTag(txtAccessories.Text);
        txtConvictedReason.Text = General.ClearScriptTag(txtConvictedReason.Text);
        txtPIReason.Text = General.ClearScriptTag(txtPIReason.Text);
        txtITReason.Text = General.ClearScriptTag(txtITReason.Text);
        txtRefusedReason.Text = General.ClearScriptTag(txtRefusedReason.Text);

        #region NCD

        if (ddlNCDReason.SelectedItem.Text == "Others")
        {
            rfvNCDReasonSave.Enabled = true;
        }
        else
        {
            rfvNCDReasonSave.Enabled = false;
        }
        #endregion
    }

    private bool SaveDemeritPoints()
    {
        //bool _result = false;
        if (lblCarId.Text != string.Empty && lblCustomerId.Text != string.Empty
            && lblProviderCompanyId.Text != string.Empty)
        {
            _CarId = Convert.ToInt64(lblCarId.Text);
            _UserId = Convert.ToInt64(lblCustomerId.Text);
            _ProviderId = Convert.ToInt64(lblProviderCompanyId.Text);
            _CarMoreId = Convert.ToInt64(lblCarMoreDetailId.Text);
        }
        else if (Session[General.CarId] != null && Session[General.UserId] != null
            && lblProviderCompanyId.Text != string.Empty)
        {
            _CarId = Convert.ToInt64(Session[General.CarId].ToString());
            _UserId = Convert.ToInt64(Session[General.UserId].ToString());
            _ProviderId = Convert.ToInt64(Session[General.ProviderCompanyId].ToString());
            _CarMoreId = Convert.ToInt64(Session[General.CarMoreDetailId].ToString());
        }

        Int64 _demeritresult = 0;
        if (txtDrivername1.Text != string.Empty && txtTotalpoints1.Text != string.Empty && txtOffencetype1.Text != string.Empty)
        {
            CarDriverDemeritPoints _cardriverdemeritpoints = new CarDriverDemeritPoints();
            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
            _cardriverdemeritpoints.CECarID = _CarId;
            _cardriverdemeritpoints.CECarMoreDetailId = _CarMoreId;
            _cardriverdemeritpoints.ProviderCompanyId = _ProviderId;
            _cardriverdemeritpoints.DriverName = txtDrivername1.Text.ToUpper();
            _cardriverdemeritpoints.TotalDemeritPoints = txtTotalpoints1.Text;
            _cardriverdemeritpoints.DemeritDate = ddlDODemerit1.GetDate();
            _cardriverdemeritpoints.TypeofOffence = txtOffencetype1.Text;
            _cardriverdemeritpoints.RefCEUserId = _UserId;
            _cardriverdemeritpoints.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _cardriverdemeritpoints.Status = true;
            _demeritresult += _cardriverdemeritpointsdb.InsertLiberty(_cardriverdemeritpoints);
            _cardriverdemeritpoints = null;
            _cardriverdemeritpointsdb = null;
        }

        if (txtDrivername2.Text != string.Empty && txtTotalpoints2.Text != string.Empty && txtOffencetype2.Text != string.Empty)
        {
            CarDriverDemeritPoints _cardriverdemeritpoints = new CarDriverDemeritPoints();
            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
            _cardriverdemeritpoints.CECarID = _CarId;
            _cardriverdemeritpoints.CECarMoreDetailId = _CarMoreId;
            _cardriverdemeritpoints.ProviderCompanyId = _ProviderId;
            _cardriverdemeritpoints.DriverName = txtDrivername2.Text.ToUpper();
            _cardriverdemeritpoints.TotalDemeritPoints = txtTotalpoints2.Text;
            _cardriverdemeritpoints.DemeritDate = ddlDODemerit2.GetDate();
            _cardriverdemeritpoints.TypeofOffence = txtOffencetype2.Text;
            _cardriverdemeritpoints.RefCEUserId = _UserId;
            _cardriverdemeritpoints.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _cardriverdemeritpoints.Status = true;
            _demeritresult += _cardriverdemeritpointsdb.InsertLiberty(_cardriverdemeritpoints);
            _cardriverdemeritpoints = null;
            _cardriverdemeritpointsdb = null;
        }

        if (txtDrivername3.Text != string.Empty && txtTotalpoints3.Text != string.Empty && txtOffencetype3.Text != string.Empty)
        {
            CarDriverDemeritPoints _cardriverdemeritpoints = new CarDriverDemeritPoints();
            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
            _cardriverdemeritpoints.CECarID = _CarId;
            _cardriverdemeritpoints.CECarMoreDetailId = _CarMoreId;
            _cardriverdemeritpoints.ProviderCompanyId = _ProviderId;
            _cardriverdemeritpoints.DriverName = txtDrivername3.Text.ToUpper();
            _cardriverdemeritpoints.TotalDemeritPoints = txtTotalpoints3.Text;
            _cardriverdemeritpoints.DemeritDate = ddlDODemerit3.GetDate();
            _cardriverdemeritpoints.TypeofOffence = txtOffencetype3.Text;
            _cardriverdemeritpoints.RefCEUserId = _UserId;
            _cardriverdemeritpoints.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _cardriverdemeritpoints.Status = true;
            _demeritresult += _cardriverdemeritpointsdb.InsertLiberty(_cardriverdemeritpoints);
            _cardriverdemeritpoints = null;
            _cardriverdemeritpointsdb = null;
        }

        if (txtDrivername4.Text != string.Empty && txtTotalpoints4.Text != string.Empty && txtOffencetype4.Text != string.Empty)
        {
            CarDriverDemeritPoints _cardriverdemeritpoints = new CarDriverDemeritPoints();
            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
            _cardriverdemeritpoints.CECarID = _CarId;
            _cardriverdemeritpoints.CECarMoreDetailId = _CarMoreId;
            _cardriverdemeritpoints.ProviderCompanyId = _ProviderId;
            _cardriverdemeritpoints.DriverName = txtDrivername4.Text.ToUpper();
            _cardriverdemeritpoints.TotalDemeritPoints = txtTotalpoints4.Text;
            _cardriverdemeritpoints.DemeritDate = ddlDODemerit4.GetDate();
            _cardriverdemeritpoints.TypeofOffence = txtOffencetype4.Text;
            _cardriverdemeritpoints.RefCEUserId = _UserId;
            _cardriverdemeritpoints.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _cardriverdemeritpoints.Status = true;
            _demeritresult += _cardriverdemeritpointsdb.InsertLiberty(_cardriverdemeritpoints);
            _cardriverdemeritpoints = null;
            _cardriverdemeritpointsdb = null;
        }

        if (txtDrivername5.Text != string.Empty && txtTotalpoints5.Text != string.Empty && txtOffencetype5.Text != string.Empty)
        {
            CarDriverDemeritPoints _cardriverdemeritpoints = new CarDriverDemeritPoints();
            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
            _cardriverdemeritpoints.CECarID = _CarId;
            _cardriverdemeritpoints.CECarMoreDetailId = _CarMoreId;
            _cardriverdemeritpoints.ProviderCompanyId = _ProviderId;
            _cardriverdemeritpoints.DriverName = txtDrivername5.Text.ToUpper();
            _cardriverdemeritpoints.TotalDemeritPoints = txtTotalpoints5.Text;
            _cardriverdemeritpoints.DemeritDate = ddlDODemerit5.GetDate();
            _cardriverdemeritpoints.TypeofOffence = txtOffencetype5.Text;
            _cardriverdemeritpoints.RefCEUserId = _UserId;
            _cardriverdemeritpoints.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _cardriverdemeritpoints.Status = true;
            _demeritresult += _cardriverdemeritpointsdb.InsertLiberty(_cardriverdemeritpoints);
            _cardriverdemeritpoints = null;
            _cardriverdemeritpointsdb = null;
        }

        if (txtDrivername6.Text != string.Empty && txtTotalpoints6.Text != string.Empty && txtOffencetype6.Text != string.Empty)
        {
            CarDriverDemeritPoints _cardriverdemeritpoints = new CarDriverDemeritPoints();
            CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
            _cardriverdemeritpoints.CECarID = _CarId;
            _cardriverdemeritpoints.CECarMoreDetailId = _CarMoreId;
            _cardriverdemeritpoints.ProviderCompanyId = _ProviderId;
            _cardriverdemeritpoints.DriverName = txtDrivername6.Text.ToUpper();
            _cardriverdemeritpoints.TotalDemeritPoints = txtTotalpoints6.Text;
            _cardriverdemeritpoints.DemeritDate = ddlDODemerit6.GetDate();
            _cardriverdemeritpoints.TypeofOffence = txtOffencetype6.Text;
            _cardriverdemeritpoints.RefCEUserId = _UserId;
            _cardriverdemeritpoints.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
            _cardriverdemeritpoints.Status = true;
            _demeritresult += _cardriverdemeritpointsdb.InsertLiberty(_cardriverdemeritpoints);
            _cardriverdemeritpoints = null;
            _cardriverdemeritpointsdb = null;
        }

        return _demeritresult > 0;
    }

    private bool UpdateDriverDetails()
    {
        bool _result = false;
        //Int64 _demeritresult = 0;
        CarDriver _cardriver = new CarDriver();
        CarDriverDB _cardriverdb = new CarDriverDB();
        if (Session[CE.Global.General.UserId] != null && Session[CE.Global.General.CarId] != null)
        {
            _UserId = Convert.ToInt64(Session[CE.Global.General.UserId].ToString());
            _CarId = Convert.ToInt64(Session[CE.Global.General.CarId].ToString());
        }
        else if (lblCarId.Text != string.Empty && lblCustomerId.Text != string.Empty)
        {
            _UserId = Convert.ToInt64(lblCustomerId.Text);
            _CarId = Convert.ToInt64(lblCarId.Text);
        }
        if (txtDriverCount.Text.Trim() != "0")
        {
            int _drivercount = Convert.ToInt32(txtDriverCount.Text.Trim());
            int _insertcount = 0;

            for (int i = 1; i <= _drivercount; i++)
            {
                _cardriver.StepId = 2;
                _cardriver.RerCEUserId = _UserId;
                _cardriver.CECarId = _CarId;
                if (i == 1)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId1.Text.Trim());
                    _cardriver.Salutation = ddlDriverSalutation1.GetSalutation();
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverSurName1.Text.ToUpper()));
                    _cardriver.GivenName = Server.HtmlEncode(General.ClearScriptTag(txtDriverGivenName1.Text.ToUpper()));
                    _cardriver.IDType = ddlDriverIdType1.GetIDType();
                    _cardriver.IDNo = ddlDriverIdNumber1.GetIdNumber();
                    _cardriver.DOB = _dtDOB1;
                    _cardriver.Status = "Active";
                }
                else if (i == 2)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId2.Text.Trim());
                    _cardriver.Salutation = ddlDriverSalutation2.GetSalutation();
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverSurName2.Text.ToUpper()));
                    _cardriver.GivenName = Server.HtmlEncode(General.ClearScriptTag(txtDriverGivenName2.Text.ToUpper()));
                    _cardriver.IDType = ddlDriverIdType2.GetIDType();
                    _cardriver.IDNo = ddlDriverIdNumber2.GetIdNumber();
                    _cardriver.DOB = _dtDOB2;
                    _cardriver.Status = "Active";
                }
                else if (i == 3)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId3.Text.Trim());
                    _cardriver.Salutation = ddlDriverSalutation3.GetSalutation();
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverSurName3.Text.ToUpper()));
                    _cardriver.GivenName = Server.HtmlEncode(General.ClearScriptTag(txtDriverGivenName3.Text.ToUpper()));
                    _cardriver.IDType = ddlDriverIdType3.GetIDType();
                    _cardriver.IDNo = ddlDriverIdNumber3.GetIdNumber();
                    _cardriver.DOB = _dtDOB3;
                    _cardriver.Status = "Active";
                }
                else if (i == 4)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId4.Text.Trim());
                    _cardriver.Salutation = ddlDriverSalutation4.GetSalutation();
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverSurName4.Text.ToUpper()));
                    _cardriver.GivenName = Server.HtmlEncode(General.ClearScriptTag(txtDriverGivenName4.Text.ToUpper()));
                    _cardriver.IDType = ddlDriverIdType4.GetIDType();
                    _cardriver.IDNo = ddlDriverIdNumber4.GetIdNumber();
                    _cardriver.DOB = _dtDOB4;
                    _cardriver.Status = "Active";
                }
                else if (i == 5)
                {
                    _cardriver.CarDriverId = Convert.ToInt64(lblDriverId5.Text.Trim());
                    _cardriver.Salutation = ddlDriverSalutation5.GetSalutation();
                    _cardriver.Surname = Server.HtmlEncode(General.ClearScriptTag(txtDriverSurName5.Text.ToUpper()));
                    _cardriver.GivenName = Server.HtmlEncode(General.ClearScriptTag(txtDriverGivenName5.Text.ToUpper()));
                    _cardriver.IDType = ddlDriverIdType5.GetIDType();
                    _cardriver.IDNo = ddlDriverIdNumber5.GetIdNumber();
                    _cardriver.DOB = _dtDOB5;
                    _cardriver.Status = "Active";
                }
                _cardriver.ViewedDetailId = Convert.ToInt64(Session[General.ViewedDetailsId].ToString());
                if (_cardriverdb.Insert(_cardriver) > 0)
                {
                    _insertcount++;
                    _result = true;
                }
            }
            _cardriverdb = null;
            _cardriver = null;
        }
        return _result;
    }

    public string Encode(string sData)
    {
        byte[] encData_byte = new byte[sData.Length];
        encData_byte = System.Text.Encoding.UTF8.GetBytes(sData);
        string encodedData = Convert.ToBase64String(encData_byte);
        return encodedData;
    }

    private void ProposalNotification()
    {
        string _strSql, _providerName, _providerEmail, _providerCCEmail, _providerBCCEmail, _Date, _Time, _InsuranceName, _RefNo;
        MyDatabase _db = new MyDatabase();
        DataTable _dtProvider = new DataTable();
        DataTable _dtInsurance = new DataTable();
        _Date = "";
        _Time = "";
        _RefNo = "";
        _strSql = "";
        _providerName = "";
        _providerEmail = "";
        _providerCCEmail = "";
        _providerBCCEmail = "";
        _InsuranceName = "Car Insurance";

        if (lblCarId.Text != string.Empty && lblProviderCompanyId.Text != string.Empty)
        {
            _ProviderId = Convert.ToInt64(lblProviderCompanyId.Text);
            _CarId = Convert.ToInt64(lblCarId.Text);
        }
        else if (Session[General.ProviderCompanyId] != null && Session[General.CarId] != null)
        {
            _ProviderId = Convert.ToInt64(Session[General.ProviderCompanyId].ToString());
            _CarId = Convert.ToInt64(Session[General.CarId].ToString());
        }
        _strSql = "SELECT [CompanyName], [Email1] FROM tblProviderCompany WHERE ProviderCompanyId = " + _ProviderId.ToString();

        _dtProvider = _db.GetDataTable(_strSql);
        if (_dtProvider.Rows.Count > 0)
        {
            _providerName = _dtProvider.Rows[0]["CompanyName"].ToString();
            //_providerEmail = _dtProvider.Rows[0]["Email1"].ToString();          
            _providerEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("LibertyCI_TO");
            _providerCCEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("LibertyCI_CC");
            _providerBCCEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("LibertyCI_BCC");
        }
        _strSql = "";
        _strSql = "SELECT CONVERT(VARCHAR,ModifiedDate,103) AS [Date], CONVERT(VARCHAR,ModifiedDate,108) AS [Time] ";
        _strSql += " FROM  tblCarMoreDetail_Liberty WHERE CECarId = " + _CarId.ToString() + " ORDER BY ModifiedDate DESC";
        _dtInsurance = _db.GetDataTable(_strSql);
        if (_dtInsurance.Rows.Count > 0)
        {
            _Date = _dtInsurance.Rows[0]["Date"].ToString();
            _Time = _dtInsurance.Rows[0]["Time"].ToString();
        }
        //_RefNo = General.GetRefNumber("CI", _Date, Session[General.CarId].ToString());
        _RefNo = lblQRefNo.Text.Trim();
        if ((_dtProvider.Rows.Count > 0) && (_dtInsurance.Rows.Count > 0))
        {
            MyMailManager.SendProposalCompleteNotificationWithAttachment(_providerName, _providerEmail, _providerCCEmail, _providerBCCEmail, _InsuranceName, _Date, _Time, _RefNo, GeneratePDFProposalForm(_CarId, 1));

            string chkprov_email = _providerEmail.Trim();


            string ccemail = "";
            if (chkprov_email.Remove(0, chkprov_email.Length - 1) == ";")
            {
                ccemail = _providerEmail + _providerCCEmail;
            }
            else
            {
                ccemail = _providerEmail + ";" + _providerCCEmail;
            }

            string _PaymentMode = "CreditCard";
            if (rdoCash.Checked)
            {
                _PaymentMode = "Cash";
            }

            //NO CC Email to Provider for Customer email sending (PHYO)
            ccemail = string.Empty;

            MyMailManager.SendCarLibertyProposalToUserWithAttachment(_providerName, getUserEmail(), ccemail, _providerBCCEmail, _InsuranceName, _Date, _Time, _RefNo, GeneratePDFProposalForm(_CarId, 0), _PaymentMode);
        }

    }

    private string getUserEmail()
    {
        string UserEmail = "";
        Account _account = new Account();
        AccountDB _accountdb = new AccountDB();
        Int64 _ceid = 0;
        if (lblAgentId.Text != string.Empty && lblCustomerId.Text != string.Empty)
        {
            _ceid = Convert.ToInt64(lblCustomerId.Text);
        }
        else if (Session[General.UserId] != null)
        {
            _ceid = Convert.ToInt64(Session[General.UserId]);
        }

        if (_ceid > 0)
        {
            _account = _accountdb.GetAccount(_ceid);
            if (_account != null)
            {
                UserEmail = _account.Email;
            }
        }

        return UserEmail;

    }

    private Int64 LogUserViewedHistory()
    {
        UserViewHistoryDB _userviewdb = new UserViewHistoryDB();
        return _userviewdb.LogViewedHistory("CI", Request, "Car Insurance Liberty proposal form.");
    }

    private PostCode GetPostCode(string strPostCode)
    {
        PostCode _postcode = new PostCode();
        PostCodeDB _postcodedb = new PostCodeDB();
        _postcode = _postcodedb.GetPostCode(strPostCode);
        _postcodedb = null;
        return _postcode;
    }

    private void ShowCarMoreDetail(Int64 CarId, Int64 CEId)
    {
        LibertyCarMoreDetail _libertycarmoredetail = new LibertyCarMoreDetail();
        LibertyCarMoreDetailDB _libertycarmoredetaildb = new LibertyCarMoreDetailDB();
        _libertycarmoredetail = _libertycarmoredetaildb.GetCarMoreDetail(CarId, CEId);
        if (_libertycarmoredetail != null)
        {
            CarMoreDetailSetProperty(_libertycarmoredetail);
        }
        _libertycarmoredetail = null;
        _libertycarmoredetaildb = null;
    }

    private void CarMoreDetailSetProperty(LibertyCarMoreDetail _libertycarmoredetail)
    {
        if (lblCarId.Text != string.Empty && lblCustomerId.Text != string.Empty
            && lblProviderCompanyId.Text != string.Empty && lblCarResultId.Text != string.Empty)
        {
            lblCarMoreDetailId.Text = _libertycarmoredetail.CECarMoreDetailId.ToString();
        }
        else if (Session[General.CarId] != null && Session[General.UserId] != null
            && Session[General.ProviderCompanyId] != null && Session[General.CarResultId] != null)
        {
            Session[General.CarMoreDetailId] = _libertycarmoredetail.CECarMoreDetailId.ToString();
        }

        txtName.Text = _libertycarmoredetail.Name.ToString();
        txtPostCode.Text = _libertycarmoredetail.PostalCode.ToString();
        txtUnit1.Text = _libertycarmoredetail.UnitNo.ToString();
        txtUnit2.Text = _libertycarmoredetail.HomeNo.ToString();
        txtAddress.Text = _libertycarmoredetail.Address.ToString();
        txtAddress.ReadOnly = true;
        txtEmpName.Text = _libertycarmoredetail.EmpNameandTrade.ToString();
        txtMobileNo.PhoneNo = _libertycarmoredetail.MobileNo.ToString();
        txtResidentialPhoneNo.PhoneNo = _libertycarmoredetail.HomePhoneNo.ToString();
        txtOfficePhoneNo.PhoneNo = _libertycarmoredetail.OfficePhoneNo.ToString();
        if (_libertycarmoredetail.NRICNo.Length == 9)
        {
            ddlIdNumber.Prefix = _libertycarmoredetail.NRICNo[0].ToString();
            ddlIdNumber.Postfix = _libertycarmoredetail.NRICNo[8].ToString();
            ddlIdNumber.IDNumber = _libertycarmoredetail.NRICNo.Substring(1, 7);
        }
        ddlNationality.Nationality = _libertycarmoredetail.Nationality;
        ddlDrivetowestmalaysia.SelectedValue = _libertycarmoredetail.HasDriveWestMalaysia.ToString();
        ddlNCDReason.SelectedValue = _libertycarmoredetail.NCDReason.ToString();
        if (_libertycarmoredetail.NCDReason.ToString() == "Others")
        {
            txtNCDReason.Text = _libertycarmoredetail.NCDOtherReason.ToString();
        }
        txtVehicleNo.Text = _libertycarmoredetail.VechicleNo.ToString();
        //txtOdometerReading.Text = _libertycarmoredetail.OdometerReading.ToString();
        ddlDORegisteration.Day = _libertycarmoredetail.DateofRegistration.Day;
        ddlDORegisteration.Month = _libertycarmoredetail.DateofRegistration.Month;
        ddlDORegisteration.Year = _libertycarmoredetail.DateofRegistration.Year;
        txtEngineNo.Text = _libertycarmoredetail.EngineNo.ToString();
        txtChassisNo.Text = _libertycarmoredetail.ChassisNo.ToString();
        //txtEstimateMarketValue.Text = _libertycarmoredetail.EstimateMarketValue.ToString();
        if (_libertycarmoredetail.HasHirePurchase == true)
        {
            rdoYesHirePurchase.Checked = true;
            txtHirePurchase.Text = "1";

            ddlHirePurchaseCompany.Text = _libertycarmoredetail.HPCompanyName.ToString();
            //txtHPostCode.Text = _libertycarmoredetail.HPCPostalCode.ToString();
            //txtHUnit1.Text = _libertycarmoredetail.HPCUnitNo.ToString();
            //txtHUnit2.Text = _libertycarmoredetail.HPCHomeNo.ToString();
            //txtHAddress.Text = _libertycarmoredetail.HPCAddress.ToString();
        }
        else
        {
            rdoNoHirePurchase.Checked = true;
            txtHirePurchase.Text = "1";

            //txtHirePurchaseCompany.Text = "";
            //txtHPostCode.Text = "";
            //txtHUnit1.Text = "";
            //txtHUnit2.Text = "";
            //txtHAddress.Text = "";
        }
        if (_libertycarmoredetail.HasPreInsurer == true)
        {
            //rdoYesOtherInsurence.Checked = true;
            //txtOI.Text = "1";

            ddlCurInsuranceCompany.Text = _libertycarmoredetail.PreInsurerName.ToString();
            txtInsVehicleNo.Text = _libertycarmoredetail.PreInsVechicleNo.ToString();
            //txtInsPolicyNo.Text = _libertycarmoredetail.PreInsPolicyNo.ToString();
            ddlDOCancellation.Day = _libertycarmoredetail.PreInsExpiryDate.Day;
            ddlDOCancellation.Month = _libertycarmoredetail.PreInsExpiryDate.Month;
            ddlDOCancellation.Year = _libertycarmoredetail.PreInsExpiryDate.Year;
            //ddlNCD.Text = _libertycarmoredetail.NCDEntitlement.ToString();
        }
        else
        {
            //rdoNoOtherInsurence.Checked = true;
            //txtOI.Text = "1";

            ddlCurInsuranceCompany.Text = _libertycarmoredetail.PreInsurerName.ToString();
            txtInsVehicleNo.Text = "";
            //txtInsPolicyNo.Text = "";
        }
        if (_libertycarmoredetail.HasVechicleModified == true)
        {
            rdoYesVechicleModification.Checked = true;
            txtVechicleModification.Text = "1";

            txtVMReason.Text = _libertycarmoredetail.VechicleModifyReason.ToString();
        }
        else
        {
            rdoNoVechicleModification.Checked = true;
            txtVechicleModification.Text = "1";

            txtVMReason.Text = "";
        }
        if (_libertycarmoredetail.HasAccessory == true)
        {
            rdoYesAccessories.Checked = true;
            txtAccess.Text = "1";

            txtAccessories.Text = _libertycarmoredetail.AccessoryDescription.ToString();
        }
        else
        {
            rdoNoAccessories.Checked = true;
            txtAccess.Text = "1";

            txtAccessories.Text = "";
        }
        /*ddlInsurancefrom.Day = _libertycarmoredetail.InsuranceFromDate.Day;
        ddlInsurancefrom.Month = _libertycarmoredetail.InsuranceFromDate.Month;
        ddlInsurancefrom.Year = _libertycarmoredetail.InsuranceFromDate.Year;
        ddlInsuranceto.Day = _libertycarmoredetail.InsuranceToDate.Day;
        ddlInsuranceto.Month = _libertycarmoredetail.InsuranceToDate.Month;
        ddlInsuranceto.Year = _libertycarmoredetail.InsuranceToDate.Year;*/
        if (_libertycarmoredetail.HasConvictedMoterOffence == true)
        {
            rdoYesConvicted.Checked = true;
            txtConvicted.Text = "1";
            rdoNoConvicted.Checked = false;

            txtConvictedReason.Text = _libertycarmoredetail.ConvictedReason.ToString();
        }
        else
        {
            rdoNoConvicted.Checked = true;
            txtConvicted.Text = "1";

            txtConvictedReason.Text = "";
        }
        if (_libertycarmoredetail.HasDemeritPoints == true)
        {
            rdoYesDermeritPoints.Checked = true;
            txtDermeritPoints.Text = "1";
            //Response.Write(_CarMoreId);
            _CarMoreId = _libertycarmoredetail.CECarMoreDetailId;
            ShowCarDriverDemeritPoints(_CarId, _CarMoreId, _UserId, _ProviderId);

            rdoNoDermeritPoints.Checked = false;
        }
        else
        {
            rdoNoDermeritPoints.Checked = true;
            txtDermeritPoints.Text = "1";
        }
        if (_libertycarmoredetail.HasPhysicalImpairment == true)
        {
            rdoYesPhysicalimpairment.Checked = true;
            txtPhysicalimpairment.Text = "1";
            rdoNoPhysicalimpairment.Checked = false;

            txtPIReason.Text = _libertycarmoredetail.PhysicalImpairmentReason.ToString();
        }
        else
        {
            rdoNoPhysicalimpairment.Checked = true;
            txtPhysicalimpairment.Text = "1";

            txtPIReason.Text = "";
        }
        if (_libertycarmoredetail.HasInsuranceTerminated == true)
        {
            rdoYesInsuranceterminated.Checked = true;
            txtInsuranceterminated.Text = "1";
            rdoNoInsuranceterminated.Checked = false;

            txtITReason.Text = _libertycarmoredetail.InsuranceTerminatedReason.ToString();
        }
        else
        {
            rdoNoInsuranceterminated.Checked = true;
            txtInsuranceterminated.Text = "1";

            txtITReason.Text = "";
        }

        if (_libertycarmoredetail.Info1 == "1")
        {
            rdoYesRefused.Checked = true;
            txtRefused.Text = "1";
            rdoNoRefused.Checked = false;

            txtRefusedReason.Text = _libertycarmoredetail.Info2.ToString();
        }
        else
        {
            rdoNoRefused.Checked = true;
            txtRefused.Text = "1";

            txtRefusedReason.Text = "";
        }
    }

    private void ShowCarDriverDemeritPoints(Int64 CarId, Int64 CarMoreId, Int64 CEId, Int64 ProviderId)
    {
        DataSet _dsdemeritpoints = new DataSet();
        CarDriverDemeritPointsDB _cardriverdemeritpointsdb = new CarDriverDemeritPointsDB();
        _dsdemeritpoints = _cardriverdemeritpointsdb.GetCarDriverDemeritPointsLiberty(CarId, CarMoreId, CEId, ProviderId);
        if (_dsdemeritpoints.Tables[0].Rows.Count > 0)
        {
            txtDrivername1.Text = _dsdemeritpoints.Tables[0].Rows[0]["DriverName"].ToString();
            txtTotalpoints1.Text = _dsdemeritpoints.Tables[0].Rows[0]["TotalDemeritPoints"].ToString();
            ddlDODemerit1.Day = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[0]["DemeritDate"].ToString()).Day;
            ddlDODemerit1.Month = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[0]["DemeritDate"].ToString()).Month;
            ddlDODemerit1.Year = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[0]["DemeritDate"].ToString()).Year;
            txtOffencetype1.Text = _dsdemeritpoints.Tables[0].Rows[0]["TypeofOffence"].ToString();
            if (_dsdemeritpoints.Tables[0].Rows.Count > 1)
            {
                txtDrivername2.Text = _dsdemeritpoints.Tables[0].Rows[1]["DriverName"].ToString();
                txtTotalpoints2.Text = _dsdemeritpoints.Tables[0].Rows[1]["TotalDemeritPoints"].ToString();
                ddlDODemerit2.Day = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[1]["DemeritDate"].ToString()).Day;
                ddlDODemerit2.Month = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[1]["DemeritDate"].ToString()).Month;
                ddlDODemerit2.Year = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[1]["DemeritDate"].ToString()).Year;
                txtOffencetype2.Text = _dsdemeritpoints.Tables[0].Rows[1]["TypeofOffence"].ToString();
            }
            if (_dsdemeritpoints.Tables[0].Rows.Count > 2)
            {
                txtDrivername3.Text = _dsdemeritpoints.Tables[0].Rows[2]["DriverName"].ToString();
                txtTotalpoints3.Text = _dsdemeritpoints.Tables[0].Rows[2]["TotalDemeritPoints"].ToString();
                ddlDODemerit3.Day = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[2]["DemeritDate"].ToString()).Day;
                ddlDODemerit3.Month = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[2]["DemeritDate"].ToString()).Month;
                ddlDODemerit3.Year = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[2]["DemeritDate"].ToString()).Year;
                txtOffencetype3.Text = _dsdemeritpoints.Tables[0].Rows[2]["TypeofOffence"].ToString();
            }
            if (_dsdemeritpoints.Tables[0].Rows.Count > 3)
            {
                txtDrivername4.Text = _dsdemeritpoints.Tables[0].Rows[3]["DriverName"].ToString();
                txtTotalpoints4.Text = _dsdemeritpoints.Tables[0].Rows[3]["TotalDemeritPoints"].ToString();
                ddlDODemerit4.Day = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[3]["DemeritDate"].ToString()).Day;
                ddlDODemerit4.Month = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[3]["DemeritDate"].ToString()).Month;
                ddlDODemerit4.Year = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[3]["DemeritDate"].ToString()).Year;
                txtOffencetype4.Text = _dsdemeritpoints.Tables[0].Rows[3]["TypeofOffence"].ToString();
            }
            if (_dsdemeritpoints.Tables[0].Rows.Count > 4)
            {
                txtDrivername5.Text = _dsdemeritpoints.Tables[0].Rows[4]["DriverName"].ToString();
                txtTotalpoints5.Text = _dsdemeritpoints.Tables[0].Rows[4]["TotalDemeritPoints"].ToString();
                ddlDODemerit5.Day = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[4]["DemeritDate"].ToString()).Day;
                ddlDODemerit5.Month = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[4]["DemeritDate"].ToString()).Month;
                ddlDODemerit5.Year = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[4]["DemeritDate"].ToString()).Year;
                txtOffencetype5.Text = _dsdemeritpoints.Tables[0].Rows[4]["TypeofOffence"].ToString();
            }
            if (_dsdemeritpoints.Tables[0].Rows.Count > 5)
            {
                txtDrivername6.Text = _dsdemeritpoints.Tables[0].Rows[5]["DriverName"].ToString();
                txtTotalpoints6.Text = _dsdemeritpoints.Tables[0].Rows[5]["TotalDemeritPoints"].ToString();
                ddlDODemerit6.Day = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[5]["DemeritDate"].ToString()).Day;
                ddlDODemerit6.Month = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[5]["DemeritDate"].ToString()).Month;
                ddlDODemerit6.Year = Convert.ToDateTime(_dsdemeritpoints.Tables[0].Rows[5]["DemeritDate"].ToString()).Year;
                txtOffencetype6.Text = _dsdemeritpoints.Tables[0].Rows[5]["TypeofOffence"].ToString();
            }
        }
        _cardriverdemeritpointsdb = null;
    }

    private void ChangeValidationEffectServerSide(string strValidationGroup)
    {
        #region Proposal Details
        //Name
        if (rfvName.Enabled && rfvName.ValidationGroup == strValidationGroup)
        {
            rfvName.Validate();
            if (rfvName.IsValid == false)
            {
                txtName.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtName.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtName.ControlStyle.CssClass = "";
        }

        if (revName.Enabled && revName.ValidationGroup == strValidationGroup)
        {
            if (rfvName.IsValid)
            {
                revName.Validate();
                if (revName.IsValid == false)
                {
                    txtName.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtName.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtName.ControlStyle.CssClass = "";
        }
        //Postal Code
        if (rfvPostCode.Enabled && rfvPostCode.ValidationGroup == strValidationGroup)
        {
            rfvPostCode.Validate();
            if (rfvPostCode.IsValid == false)
            {
                txtPostCode.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtPostCode.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtPostCode.ControlStyle.CssClass = "";
        }

        if (revPostCode.Enabled && revPostCode.ValidationGroup == strValidationGroup)
        {
            if (rfvPostCode.IsValid)
            {
                revPostCode.Validate();
                if (revPostCode.IsValid == false)
                {
                    txtPostCode.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtPostCode.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtPostCode.ControlStyle.CssClass = "";
        }

        //Unit No
        if (rfvUnit1.Enabled && rfvUnit1.ValidationGroup == strValidationGroup)
        {
            rfvUnit1.Validate();
            if (rfvUnit1.IsValid == false)
            {
                txtUnit1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtUnit1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtUnit1.ControlStyle.CssClass = "";
        }

        //Home No
        if (rfvUnit2.Enabled && rfvUnit2.ValidationGroup == strValidationGroup)
        {
            rfvUnit2.Validate();
            if (rfvUnit2.IsValid == false)
            {
                txtUnit2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtUnit2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtUnit2.ControlStyle.CssClass = "";
        }

        //Address
        if (rfvAddress.Enabled && rfvAddress.ValidationGroup == strValidationGroup)
        {
            rfvAddress.Validate();
            if (rfvAddress.IsValid == false)
            {
                txtAddress.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtAddress.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtAddress.ControlStyle.CssClass = "";
        }

        //if (revAddress.Enabled && revAddress.ValidationGroup == strValidationGroup)
        //{
        //    if (rfvAddress.IsValid)
        //    {
        //        revAddress.Validate();
        //        if (revAddress.IsValid == false)
        //        {
        //            txtAddress.ControlStyle.CssClass = "validationError";
        //        }
        //        else
        //        {
        //            txtAddress.ControlStyle.CssClass = "";
        //        }
        //    }
        //}
        //else
        //{
        //    txtAddress.ControlStyle.CssClass = "";
        //}

        //Applicant's Mobile Number
        txtMobileNo.ChangeValidationEffectServerSide(strValidationGroup);
        txtOfficePhoneNo.ChangeValidationEffectServerSide(strValidationGroup);

        //Employer Name
        //if (rfvEmpName.Enabled && rfvEmpName.ValidationGroup == strValidationGroup)
        //{
        //    rfvEmpName.Validate();
        //    if (rfvEmpName.IsValid == false)
        //    {
        //        txtEmpName.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtEmpName.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtEmpName.ControlStyle.CssClass = "";
        //}

        if (revEmpName.Enabled && revEmpName.ValidationGroup == strValidationGroup)
        {
            //if (rfvEmpName.IsValid)
            //{
            revEmpName.Validate();
            if (revEmpName.IsValid == false)
            {
                txtEmpName.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtEmpName.ControlStyle.CssClass = "";
            }
            //}
        }
        else
        {
            txtEmpName.ControlStyle.CssClass = "";
        }

        //Applicant's Nationality
        ddlNationality.ChangeValidationEffectServerSide(strValidationGroup);

        //Applicant's Id Number
        ddlIdNumber.ChangeValidationEffectServerSide(strValidationGroup);

        #endregion

        #region Vechicle Details
        //NCD Reason
        if (rfvNCDReason.Enabled && rfvNCDReason.ValidationGroup == strValidationGroup)
        {
            rfvNCDReason.Validate();
            if (rfvNCDReason.IsValid == false)
            {
                txtNCDReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtNCDReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtNCDReason.ControlStyle.CssClass = "";
        }
        //VehicleNo
        if (rfvVehicleNo.Enabled && rfvVehicleNo.ValidationGroup == strValidationGroup)
        {
            rfvVehicleNo.Validate();
            if (rfvVehicleNo.IsValid == false)
            {
                txtVehicleNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtVehicleNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtVehicleNo.ControlStyle.CssClass = "";
        }
        //OdometerReading
        //if (rfvOdometerReading.Enabled && rfvOdometerReading.ValidationGroup == strValidationGroup)
        //{
        //    rfvOdometerReading.Validate();
        //    if (rfvOdometerReading.IsValid == false)
        //    {
        //        txtOdometerReading.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtOdometerReading.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtOdometerReading.ControlStyle.CssClass = "";
        //}

        //if (revOdometerReading.Enabled && revOdometerReading.ValidationGroup == strValidationGroup)
        //{
        //    if (rfvOdometerReading.IsValid)
        //    {
        //        revOdometerReading.Validate();
        //        if (revOdometerReading.IsValid == false)
        //        {
        //            txtOdometerReading.ControlStyle.CssClass = "validationError";
        //        }
        //        else
        //        {
        //            txtOdometerReading.ControlStyle.CssClass = "";
        //        }
        //    }
        //}
        //else
        //{
        //    txtOdometerReading.ControlStyle.CssClass = "";
        //}
        //Date Of Registeration
        ddlDORegisteration.ChangeValidationEffectServerSide(strValidationGroup);
        //EngineNo
        if (rfvEngineNo.Enabled && rfvEngineNo.ValidationGroup == strValidationGroup)
        {
            rfvEngineNo.Validate();
            if (rfvEngineNo.IsValid == false)
            {
                txtEngineNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtEngineNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtEngineNo.ControlStyle.CssClass = "";
        }
        //ChassisNo
        if (rfvChassisNo.Enabled && rfvChassisNo.ValidationGroup == strValidationGroup)
        {
            rfvChassisNo.Validate();
            if (rfvChassisNo.IsValid == false)
            {
                txtChassisNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtChassisNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtChassisNo.ControlStyle.CssClass = "";
        }
        //EstimateMarketValue
        //if (rfvEstimateMarketValue.Enabled && rfvEstimateMarketValue.ValidationGroup == strValidationGroup)
        //{
        //    rfvEstimateMarketValue.Validate();
        //    if (rfvEstimateMarketValue.IsValid == false)
        //    {
        //        txtEstimateMarketValue.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtEstimateMarketValue.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtEstimateMarketValue.ControlStyle.CssClass = "";
        //}
        //if (revEstimateMarketValue.Enabled && revEstimateMarketValue.ValidationGroup == strValidationGroup)
        //{
        //    if (rfvEstimateMarketValue.IsValid)
        //    {
        //        revEstimateMarketValue.Validate();
        //        if (revEstimateMarketValue.IsValid == false)
        //        {
        //            txtEstimateMarketValue.ControlStyle.CssClass = "validationError";
        //        }
        //        else
        //        {
        //            txtEstimateMarketValue.ControlStyle.CssClass = "";
        //        }
        //    }
        //}
        //else
        //{
        //    txtEstimateMarketValue.ControlStyle.CssClass = "";
        //}
        //Hire Purchase
        if (rfvHirePurchase.Enabled && rfvHirePurchase.ValidationGroup == strValidationGroup)
        {
            rfvHirePurchase.Validate();
            if (rfvHirePurchase.IsValid == false)
            {
                lblYesHirePurchase.ControlStyle.CssClass = "validationError";
                lblNoHirePurchase.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesHirePurchase.ControlStyle.CssClass = "";
                lblNoHirePurchase.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesHirePurchase.ControlStyle.CssClass = "";
            lblNoHirePurchase.ControlStyle.CssClass = "";
        }
        //HirePurchaseCompany
        if (rfvHirePurchaseCompany.Enabled && rfvHirePurchaseCompany.ValidationGroup == strValidationGroup)
        {
            rfvHirePurchaseCompany.Validate();
            if (rfvHirePurchaseCompany.IsValid == false)
            {
                ddlHirePurchaseCompany.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlHirePurchaseCompany.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlHirePurchaseCompany.ControlStyle.CssClass = "";
        }
        //if (revHirePurchaseCompany.Enabled && revHirePurchaseCompany.ValidationGroup == strValidationGroup)
        //{
        //    if (rfvHirePurchaseCompany.IsValid)
        //    {
        //        revHirePurchaseCompany.Validate();
        //        if (revHirePurchaseCompany.IsValid == false)
        //        {
        //            txtHirePurchaseCompany.ControlStyle.CssClass = "validationError";
        //        }
        //        else
        //        {
        //            txtHirePurchaseCompany.ControlStyle.CssClass = "";
        //        }
        //    }
        //}
        //else
        //{
        //    txtHirePurchaseCompany.ControlStyle.CssClass = "";
        //}
        //Postal Code
        //if (rfvHPostCode.Enabled && rfvHPostCode.ValidationGroup == strValidationGroup)
        //{
        //    rfvHPostCode.Validate();
        //    if (rfvHPostCode.IsValid == false)
        //    {
        //        txtHPostCode.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtHPostCode.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtHPostCode.ControlStyle.CssClass = "";
        //}

        //if (revHPostCode.Enabled && revHPostCode.ValidationGroup == strValidationGroup)
        //{
        //    if (rfvHPostCode.IsValid)
        //    {
        //        revHPostCode.Validate();
        //        if (revHPostCode.IsValid == false)
        //        {
        //            txtHPostCode.ControlStyle.CssClass = "validationError";
        //        }
        //        else
        //        {
        //            txtHPostCode.ControlStyle.CssClass = "";
        //        }
        //    }
        //}
        //else
        //{
        //    txtHPostCode.ControlStyle.CssClass = "";
        //}

        ////Unit No
        //if (rfvHUnit1.Enabled && rfvHUnit1.ValidationGroup == strValidationGroup)
        //{
        //    rfvHUnit1.Validate();
        //    if (rfvHUnit1.IsValid == false)
        //    {
        //        txtHUnit1.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtHUnit1.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtHUnit1.ControlStyle.CssClass = "";
        //}

        ////Home No
        //if (rfvHUnit2.Enabled && rfvHUnit2.ValidationGroup == strValidationGroup)
        //{
        //    rfvHUnit2.Validate();
        //    if (rfvHUnit2.IsValid == false)
        //    {
        //        txtHUnit2.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtHUnit2.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtHUnit2.ControlStyle.CssClass = "";
        //}

        ////Address
        //if (rfvHAddress.Enabled && rfvHAddress.ValidationGroup == strValidationGroup)
        //{
        //    rfvHAddress.Validate();
        //    if (rfvHAddress.IsValid == false)
        //    {
        //        txtHAddress.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtHAddress.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtHAddress.ControlStyle.CssClass = "";
        //}

        //if (revHAddress.Enabled && revHAddress.ValidationGroup == strValidationGroup)
        //{
        //    if (rfvHAddress.IsValid)
        //    {
        //        revHAddress.Validate();
        //        if (revHAddress.IsValid == false)
        //        {
        //            txtHAddress.ControlStyle.CssClass = "validationError";
        //        }
        //        else
        //        {
        //            txtHAddress.ControlStyle.CssClass = "";
        //        }
        //    }
        //}
        //else
        //{
        //    txtHAddress.ControlStyle.CssClass = "";
        //}
        //OTHER INSURANCE
        //if (rfvOI.Enabled && rfvOI.ValidationGroup == strValidationGroup)
        //{
        //    rfvOI.Validate();
        //    if (rfvOI.IsValid == false)
        //    {
        //        lblYesOtherInsurence.ControlStyle.CssClass = "validationError";
        //        lblNoOtherInsurence.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        lblYesOtherInsurence.ControlStyle.CssClass = "";
        //        lblNoOtherInsurence.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    lblYesOtherInsurence.ControlStyle.CssClass = "";
        //    lblNoOtherInsurence.ControlStyle.CssClass = "";
        //}
        //Insurance Company
        if (rfvCurInsuranceCompany.Enabled && rfvCurInsuranceCompany.ValidationGroup == strValidationGroup)
        {
            rfvCurInsuranceCompany.Validate();
            if (rfvCurInsuranceCompany.IsValid == false)
            {
                ddlCurInsuranceCompany.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlCurInsuranceCompany.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlCurInsuranceCompany.ControlStyle.CssClass = "";
        }
        //Insurance Vechicle No
        if (rfvInsVehicleNo.Enabled && rfvInsVehicleNo.ValidationGroup == strValidationGroup)
        {
            rfvInsVehicleNo.Validate();
            if (rfvInsVehicleNo.IsValid == false)
            {
                txtInsVehicleNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtInsVehicleNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtInsVehicleNo.ControlStyle.CssClass = "";
        }
        //Insurance Policy No
        //if (rfvInsPolicyNo.Enabled && rfvInsPolicyNo.ValidationGroup == strValidationGroup)
        //{
        //    rfvInsPolicyNo.Validate();
        //    if (rfvInsPolicyNo.IsValid == false)
        //    {
        //        txtInsPolicyNo.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        txtInsPolicyNo.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    txtInsPolicyNo.ControlStyle.CssClass = "";
        //}
        //Insurance Date Of Cancellation
        ddlDOCancellation.ChangeValidationEffectServerSide(strValidationGroup);
        //Insurance NCD
        //if (rfvNCD.Enabled && rfvNCD.ValidationGroup == strValidationGroup)
        //{
        //    rfvNCD.Validate();
        //    if (rfvNCD.IsValid == false)
        //    {
        //        ddlNCD.ControlStyle.CssClass = "validationError";
        //    }
        //    else
        //    {
        //        ddlNCD.ControlStyle.CssClass = "";
        //    }
        //}
        //else
        //{
        //    ddlNCD.ControlStyle.CssClass = "";
        //}
        //Vechicle Modification
        if (rfvVechicleModification.Enabled && rfvVechicleModification.ValidationGroup == strValidationGroup)
        {
            rfvVechicleModification.Validate();
            if (rfvVechicleModification.IsValid == false)
            {
                lblYesVechicleModification.ControlStyle.CssClass = "validationError";
                lblNoVechicleModification.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesVechicleModification.ControlStyle.CssClass = "";
                lblNoVechicleModification.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesVechicleModification.ControlStyle.CssClass = "";
            lblNoVechicleModification.ControlStyle.CssClass = "";
        }
        //Vechicle Modification Reason
        if (rfvVMReason.Enabled && rfvVMReason.ValidationGroup == strValidationGroup)
        {
            rfvVMReason.Validate();
            if (rfvVMReason.IsValid == false)
            {
                txtVMReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtVMReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtVMReason.ControlStyle.CssClass = "";
        }
        //Accessories
        if (rfvAccess.Enabled && rfvAccess.ValidationGroup == strValidationGroup)
        {
            rfvAccess.Validate();
            if (rfvAccess.IsValid == false)
            {
                lblYesAccessories.ControlStyle.CssClass = "validationError";
                lblNoAccessories.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesAccessories.ControlStyle.CssClass = "";
                lblNoAccessories.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesAccessories.ControlStyle.CssClass = "";
            lblNoAccessories.ControlStyle.CssClass = "";
        }
        //Accessories Reason
        if (rfvAccessories.Enabled && rfvAccessories.ValidationGroup == strValidationGroup)
        {
            rfvAccessories.Validate();
            if (rfvAccessories.IsValid == false)
            {
                txtAccessories.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtAccessories.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtAccessories.ControlStyle.CssClass = "";
        }
        //Insurance from Date
        //ddlInsurancefrom.ChangeValidationEffectServerSide(strValidationGroup);
        //Insurance to Date
        //ddlInsuranceto.ChangeValidationEffectServerSide(strValidationGroup);

        #endregion

        #region Other Info

        //Convicted
        if (rfvConvicted.Enabled && rfvConvicted.ValidationGroup == strValidationGroup)
        {
            rfvConvicted.Validate();
            if (rfvConvicted.IsValid == false)
            {
                lblYesConvicted.ControlStyle.CssClass = "validationError";
                lblNoConvicted.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesConvicted.ControlStyle.CssClass = "";
                lblNoConvicted.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesConvicted.ControlStyle.CssClass = "";
            lblNoConvicted.ControlStyle.CssClass = "";
        }
        //ConvictedReason
        if (rfvConvictedReason.Enabled && rfvConvictedReason.ValidationGroup == strValidationGroup)
        {
            rfvConvictedReason.Validate();
            if (rfvConvictedReason.IsValid == false)
            {
                txtConvictedReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtConvictedReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtConvictedReason.ControlStyle.CssClass = "";
        }

        //DermeritPoints
        if (rfvDermeritPoints.Enabled && rfvDermeritPoints.ValidationGroup == strValidationGroup)
        {
            rfvDermeritPoints.Validate();
            if (rfvDermeritPoints.IsValid == false)
            {
                lblYesDermeritPoints.ControlStyle.CssClass = "validationError";
                lblNoDermeritPoints.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesDermeritPoints.ControlStyle.CssClass = "";
                lblNoDermeritPoints.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesDermeritPoints.ControlStyle.CssClass = "";
            lblNoDermeritPoints.ControlStyle.CssClass = "";
        }
        //Drivername
        if (rfvDrivername1.Enabled && rfvDrivername1.ValidationGroup == strValidationGroup)
        {
            rfvDrivername1.Validate();
            if (rfvDrivername1.IsValid == false)
            {
                txtDrivername1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDrivername1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDrivername1.ControlStyle.CssClass = "";
        }
        //Totalpoints
        if (rfvTotalpoints1.Enabled && rfvTotalpoints1.ValidationGroup == strValidationGroup)
        {
            rfvTotalpoints1.Validate();
            if (rfvTotalpoints1.IsValid == false)
            {
                txtTotalpoints1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtTotalpoints1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtTotalpoints1.ControlStyle.CssClass = "";
        }
        //Offencetype
        if (rfvOffencetype1.Enabled && rfvOffencetype1.ValidationGroup == strValidationGroup)
        {
            rfvOffencetype1.Validate();
            if (rfvOffencetype1.IsValid == false)
            {
                txtOffencetype1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtOffencetype1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtOffencetype1.ControlStyle.CssClass = "";
        }
        //Date Of Demerit 1
        ddlDODemerit1.ChangeValidationEffectServerSide(strValidationGroup);
        //Date Of Demerit 2
        ddlDODemerit2.ChangeValidationEffectServerSide(strValidationGroup);
        //Date Of Demerit 3
        ddlDODemerit3.ChangeValidationEffectServerSide(strValidationGroup);
        //Date Of Demerit 4
        ddlDODemerit4.ChangeValidationEffectServerSide(strValidationGroup);
        //Date Of Demerit 5
        ddlDODemerit5.ChangeValidationEffectServerSide(strValidationGroup);
        //Date Of Demerit 6
        ddlDODemerit6.ChangeValidationEffectServerSide(strValidationGroup);

        //Physicalimpairment
        if (rfvPhysicalimpairment.Enabled && rfvPhysicalimpairment.ValidationGroup == strValidationGroup)
        {
            rfvPhysicalimpairment.Validate();
            if (rfvPhysicalimpairment.IsValid == false)
            {
                lblYesPhysicalimpairment.ControlStyle.CssClass = "validationError";
                lblNoPhysicalimpairment.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesPhysicalimpairment.ControlStyle.CssClass = "";
                lblNoPhysicalimpairment.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesPhysicalimpairment.ControlStyle.CssClass = "";
            lblNoPhysicalimpairment.ControlStyle.CssClass = "";
        }
        //Physicalimpairment Reason
        if (rfvPIReason.Enabled && rfvPIReason.ValidationGroup == strValidationGroup)
        {
            rfvPIReason.Validate();
            if (rfvPIReason.IsValid == false)
            {
                txtPIReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtPIReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtPIReason.ControlStyle.CssClass = "";
        }

        //Insurance Terminated
        if (rfvInsuranceterminated.Enabled && rfvInsuranceterminated.ValidationGroup == strValidationGroup)
        {
            rfvInsuranceterminated.Validate();
            if (rfvInsuranceterminated.IsValid == false)
            {
                lblYesInsuranceterminated.ControlStyle.CssClass = "validationError";
                lblNoInsuranceterminated.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesInsuranceterminated.ControlStyle.CssClass = "";
                lblNoInsuranceterminated.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesInsuranceterminated.ControlStyle.CssClass = "";
            lblNoInsuranceterminated.ControlStyle.CssClass = "";
        }
        //Insurance Terminated Reason
        if (rfvITReason.Enabled && rfvITReason.ValidationGroup == strValidationGroup)
        {
            rfvITReason.Validate();
            if (rfvITReason.IsValid == false)
            {
                txtITReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtITReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtITReason.ControlStyle.CssClass = "";
        }

        //Insurance Refused
        if (rfvRefused.Enabled && rfvRefused.ValidationGroup == strValidationGroup)
        {
            rfvRefused.Validate();
            if (rfvRefused.IsValid == false)
            {
                lblYesRefused.ControlStyle.CssClass = "validationError";
                lblNoRefused.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblYesRefused.ControlStyle.CssClass = "";
                lblNoRefused.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblYesRefused.ControlStyle.CssClass = "";
            lblNoRefused.ControlStyle.CssClass = "";
        }

        //Insurance Refused Reason
        if (rfvRefusedReason.Enabled && rfvRefusedReason.ValidationGroup == strValidationGroup)
        {
            rfvRefusedReason.Validate();
            if (rfvRefusedReason.IsValid == false)
            {
                txtRefusedReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtRefusedReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtRefusedReason.ControlStyle.CssClass = "";
        }

        #endregion

        #region Payment Mode

        //Name of the Card
        if (rfvNameoftheCard.Enabled && rfvNameoftheCard.ValidationGroup == strValidationGroup)
        {
            rfvNameoftheCard.Validate();
            if (rfvNameoftheCard.IsValid == false)
            {
                txtNameoftheCard.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtNameoftheCard.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtNameoftheCard.ControlStyle.CssClass = "";
        }
        //Issuing Bank
        if (rfvIssuingBank.Enabled && rfvIssuingBank.ValidationGroup == strValidationGroup)
        {
            rfvIssuingBank.Validate();
            if (rfvIssuingBank.IsValid == false)
            {
                txtIssuingBank.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtIssuingBank.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtIssuingBank.ControlStyle.CssClass = "";
        }
        //Card 1
        if (rfvCardNo1.Enabled && rfvCardNo1.ValidationGroup == strValidationGroup)
        {
            rfvCardNo1.Validate();
            if (rfvCardNo1.IsValid == false)
            {
                txtCardNo1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtCardNo1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtCardNo1.ControlStyle.CssClass = "";
        }

        if (revCardNo1.Enabled && revCardNo1.ValidationGroup == strValidationGroup)
        {
            if (rfvCardNo1.IsValid)
            {
                revCardNo1.Validate();
                if (revCardNo1.IsValid == false)
                {
                    txtCardNo1.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtCardNo1.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtCardNo1.ControlStyle.CssClass = "";
        }
        //Card 2
        if (rfvCardNo2.Enabled && rfvCardNo2.ValidationGroup == strValidationGroup)
        {
            rfvCardNo2.Validate();
            if (rfvCardNo2.IsValid == false)
            {
                txtCardNo2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtCardNo2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtCardNo2.ControlStyle.CssClass = "";
        }

        if (revCardNo2.Enabled && revCardNo2.ValidationGroup == strValidationGroup)
        {
            if (rfvCardNo2.IsValid)
            {
                revCardNo2.Validate();
                if (revCardNo2.IsValid == false)
                {
                    txtCardNo2.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtCardNo2.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtCardNo2.ControlStyle.CssClass = "";
        }
        //Card 3
        if (rfvCardNo3.Enabled && rfvCardNo3.ValidationGroup == strValidationGroup)
        {
            rfvCardNo3.Validate();
            if (rfvCardNo3.IsValid == false)
            {
                txtCardNo3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtCardNo3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtCardNo3.ControlStyle.CssClass = "";
        }

        if (revCardNo3.Enabled && revCardNo3.ValidationGroup == strValidationGroup)
        {
            if (rfvCardNo3.IsValid)
            {
                revCardNo3.Validate();
                if (revCardNo3.IsValid == false)
                {
                    txtCardNo3.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtCardNo3.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtCardNo3.ControlStyle.CssClass = "";
        }
        //Card 4
        if (rfvCardNo4.Enabled && rfvCardNo4.ValidationGroup == strValidationGroup)
        {
            rfvCardNo4.Validate();
            if (rfvCardNo4.IsValid == false)
            {
                txtCardNo4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtCardNo4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtCardNo4.ControlStyle.CssClass = "";
        }

        if (revCardNo4.Enabled && revCardNo4.ValidationGroup == strValidationGroup)
        {
            if (rfvCardNo4.IsValid)
            {
                revCardNo4.Validate();
                if (revCardNo4.IsValid == false)
                {
                    txtCardNo4.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtCardNo4.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtCardNo4.ControlStyle.CssClass = "";
        }
        //Card Expiry Month
        if (rfvCardExpiryMonth.Enabled && rfvCardExpiryMonth.ValidationGroup == strValidationGroup)
        {
            rfvCardExpiryMonth.Validate();
            if (rfvCardExpiryMonth.IsValid == false)
            {
                ddlCardExpiryMonth.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlCardExpiryMonth.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlCardExpiryMonth.ControlStyle.CssClass = "";
        }

        //if (revCardExpiryMonth.Enabled && revCardExpiryMonth.ValidationGroup == strValidationGroup)
        //{
        //    if (rfvCardExpiryMonth.IsValid)
        //    {
        //        revCardExpiryMonth.Validate();
        //        if (revCardExpiryMonth.IsValid == false)
        //        {
        //            txtCardExpiryMonth.ControlStyle.CssClass = "validationError";
        //        }
        //        else
        //        {
        //            txtCardExpiryMonth.ControlStyle.CssClass = "";
        //        }
        //    }
        //}
        //else
        //{
        //    txtCardExpiryMonth.ControlStyle.CssClass = "";
        //}
        //Card Expiry Year
        if (rfvCardExpiryYear.Enabled && rfvCardExpiryYear.ValidationGroup == strValidationGroup)
        {
            rfvCardExpiryYear.Validate();
            if (rfvCardExpiryYear.IsValid == false)
            {
                ddlCardExpiryYear.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlCardExpiryYear.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlCardExpiryYear.ControlStyle.CssClass = "";
        }

        //if (revCardExpiryYear.Enabled && revCardExpiryYear.ValidationGroup == strValidationGroup)
        //{
        //    if (rfvCardExpiryYear.IsValid)
        //    {
        //        revCardExpiryYear.Validate();
        //        if (revCardExpiryYear.IsValid == false)
        //        {
        //            txtCardExpiryYear.ControlStyle.CssClass = "validationError";
        //        }
        //        else
        //        {
        //            txtCardExpiryYear.ControlStyle.CssClass = "";
        //        }
        //    }
        //}
        //else
        //{
        //    txtCardExpiryYear.ControlStyle.CssClass = "";
        //}
        //CardType
        if (rfvCardType.Enabled && rfvCardType.ValidationGroup == strValidationGroup)
        {
            rfvCardType.Validate();
            if (rfvCardType.IsValid == false)
            {
                lblVisa.ControlStyle.CssClass = "validationError";
                lblMasterCard.ControlStyle.CssClass = "validationError";
            }
            else
            {
                lblVisa.ControlStyle.CssClass = "";
                lblMasterCard.ControlStyle.CssClass = "";
            }
        }
        else
        {
            lblVisa.ControlStyle.CssClass = "";
            lblMasterCard.ControlStyle.CssClass = "";
        }

        #endregion

        #region Drivers
        //Driver 1 **************************************************************
        //Salutation
        ddlDriverSalutation1.ChangeValidationEffectServerSide(strValidationGroup);
        //Name
        if (rfvDriverSurName1.Enabled && rfvDriverSurName1.ValidationGroup == strValidationGroup)
        {
            rfvDriverSurName1.Validate();
            if (rfvDriverSurName1.IsValid == false)
            {
                txtDriverSurName1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverSurName1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverSurName1.ControlStyle.CssClass = "";
        }

        //SalGender
        ddlDriverGender1.ChangeValidationEffectServerSide(strValidationGroup);
        if (csvDriverSalGender1.Enabled && csvDriverSalGender1.ValidationGroup == strValidationGroup)
        {
            if (ddlDriverSalutation1.IsValidRequirement() && ddlDriverGender1.IsValidRequirement())
            {
                csvDriverSalGender1.Validate();
                if (csvDriverSalGender1.IsValid == false)
                {
                    ddlDriverSalutation1.ChangeValidateEffect(true);
                }
                else
                {
                    ddlDriverSalutation1.ChangeValidateEffect(false);
                }
            }
        }
        else
        {
            ddlDriverSalutation1.ChangeValidateEffect(false);
        }

        //Type of Indentification
        ddlDriverIdType1.ChangeValidationEffectServerSide(strValidationGroup);

        //Id Number
        ddlDriverIdNumber1.ChangeValidationEffectServerSide(strValidationGroup);

        //Driver 2 **************************************************************
        //Salutation
        ddlDriverSalutation2.ChangeValidationEffectServerSide(strValidationGroup);
        //Name
        if (rfvDriverSurName2.Enabled && rfvDriverSurName2.ValidationGroup == strValidationGroup)
        {
            rfvDriverSurName2.Validate();
            if (rfvDriverSurName2.IsValid == false)
            {
                txtDriverSurName2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverSurName2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverSurName2.ControlStyle.CssClass = "";
        }

        //SalGender
        ddlDriverGender2.ChangeValidationEffectServerSide(strValidationGroup);
        if (csvDriverSalGender2.Enabled && csvDriverSalGender2.ValidationGroup == strValidationGroup)
        {
            if (ddlDriverSalutation2.IsValidRequirement() && ddlDriverGender2.IsValidRequirement())
            {
                csvDriverSalGender1.Validate();
                if (csvDriverSalGender2.IsValid == false)
                {
                    ddlDriverSalutation2.ChangeValidateEffect(true);
                }
                else
                {
                    ddlDriverSalutation2.ChangeValidateEffect(false);
                }
            }
        }
        else
        {
            ddlDriverSalutation2.ChangeValidateEffect(false);
        }

        //Type of Indentification
        ddlDriverIdType2.ChangeValidationEffectServerSide(strValidationGroup);

        //Id Number
        ddlDriverIdNumber2.ChangeValidationEffectServerSide(strValidationGroup);

        //Driver 3 **************************************************************
        //Salutation
        ddlDriverSalutation3.ChangeValidationEffectServerSide(strValidationGroup);
        //Name
        if (rfvDriverSurName3.Enabled && rfvDriverSurName3.ValidationGroup == strValidationGroup)
        {
            rfvDriverSurName3.Validate();
            if (rfvDriverSurName3.IsValid == false)
            {
                txtDriverSurName3.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverSurName3.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverSurName3.ControlStyle.CssClass = "";
        }

        //SalGender
        ddlDriverGender3.ChangeValidationEffectServerSide(strValidationGroup);
        if (csvDriverSalGender3.Enabled && csvDriverSalGender3.ValidationGroup == strValidationGroup)
        {
            if (ddlDriverSalutation3.IsValidRequirement() && ddlDriverGender3.IsValidRequirement())
            {
                csvDriverSalGender3.Validate();
                if (csvDriverSalGender3.IsValid == false)
                {
                    ddlDriverSalutation3.ChangeValidateEffect(true);
                }
                else
                {
                    ddlDriverSalutation3.ChangeValidateEffect(false);
                }
            }
        }
        else
        {
            ddlDriverSalutation3.ChangeValidateEffect(false);
        }

        //Type of Indentification
        ddlDriverIdType3.ChangeValidationEffectServerSide(strValidationGroup);

        //Id Number
        ddlDriverIdNumber3.ChangeValidationEffectServerSide(strValidationGroup);
        //Driver 4 **************************************************************
        //Salutation
        ddlDriverSalutation4.ChangeValidationEffectServerSide(strValidationGroup);
        //Name
        if (rfvDriverSurName4.Enabled && rfvDriverSurName4.ValidationGroup == strValidationGroup)
        {
            rfvDriverSurName4.Validate();
            if (rfvDriverSurName4.IsValid == false)
            {
                txtDriverSurName4.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverSurName4.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverSurName4.ControlStyle.CssClass = "";
        }

        //SalGender
        ddlDriverGender4.ChangeValidationEffectServerSide(strValidationGroup);
        if (csvDriverSalGender4.Enabled && csvDriverSalGender4.ValidationGroup == strValidationGroup)
        {
            if (ddlDriverSalutation4.IsValidRequirement() && ddlDriverGender4.IsValidRequirement())
            {
                csvDriverSalGender4.Validate();
                if (csvDriverSalGender4.IsValid == false)
                {
                    ddlDriverSalutation4.ChangeValidateEffect(true);
                }
                else
                {
                    ddlDriverSalutation4.ChangeValidateEffect(false);
                }
            }
        }
        else
        {
            ddlDriverSalutation4.ChangeValidateEffect(false);
        }

        //Type of Indentification
        ddlDriverIdType4.ChangeValidationEffectServerSide(strValidationGroup);

        //Id Number
        ddlDriverIdNumber4.ChangeValidationEffectServerSide(strValidationGroup);

        //Driver 5 **************************************************************
        //Salutation
        ddlDriverSalutation5.ChangeValidationEffectServerSide(strValidationGroup);
        //Name
        if (rfvDriverSurName5.Enabled && rfvDriverSurName5.ValidationGroup == strValidationGroup)
        {
            rfvDriverSurName5.Validate();
            if (rfvDriverSurName5.IsValid == false)
            {
                txtDriverSurName5.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtDriverSurName5.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtDriverSurName5.ControlStyle.CssClass = "";
        }

        //SalGender
        ddlDriverGender5.ChangeValidationEffectServerSide(strValidationGroup);
        if (csvDriverSalGender5.Enabled && csvDriverSalGender5.ValidationGroup == strValidationGroup)
        {
            if (ddlDriverSalutation5.IsValidRequirement() && ddlDriverGender5.IsValidRequirement())
            {
                csvDriverSalGender5.Validate();
                if (csvDriverSalGender5.IsValid == false)
                {
                    ddlDriverSalutation5.ChangeValidateEffect(true);
                }
                else
                {
                    ddlDriverSalutation5.ChangeValidateEffect(false);
                }
            }
        }
        else
        {
            ddlDriverSalutation5.ChangeValidateEffect(false);
        }

        //Type of Indentification
        ddlDriverIdType5.ChangeValidationEffectServerSide(strValidationGroup);

        //Id Number
        ddlDriverIdNumber5.ChangeValidationEffectServerSide(strValidationGroup);
        #endregion

    }

    private void ChangeValidationEffectServerSideSave(string strValidationGroup)
    {
        #region Proposal Details
        //Name
        if (rfvNameSave.Enabled && rfvNameSave.ValidationGroup == strValidationGroup)
        {
            rfvNameSave.Validate();
            if (rfvNameSave.IsValid == false)
            {
                txtName.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtName.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtName.ControlStyle.CssClass = "";
        }

        if (revNameSave.Enabled && revNameSave.ValidationGroup == strValidationGroup)
        {
            if (rfvNameSave.IsValid)
            {
                revNameSave.Validate();
                if (revNameSave.IsValid == false)
                {
                    txtName.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtName.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtName.ControlStyle.CssClass = "";
        }
        //Postal Code
        if (rfvPostCode.Enabled && rfvPostCode.ValidationGroup == strValidationGroup)
        {
            rfvPostCode.Validate();
            if (rfvPostCode.IsValid == false)
            {
                txtPostCode.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtPostCode.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtPostCode.ControlStyle.CssClass = "";
        }

        if (revPostCode.Enabled && revPostCode.ValidationGroup == strValidationGroup)
        {
            if (rfvPostCode.IsValid)
            {
                revPostCode.Validate();
                if (revPostCode.IsValid == false)
                {
                    txtPostCode.ControlStyle.CssClass = "validationError";
                }
                else
                {
                    txtPostCode.ControlStyle.CssClass = "";
                }
            }
        }
        else
        {
            txtPostCode.ControlStyle.CssClass = "";
        }

        //Unit No
        if (rfvUnit1Save.Enabled && rfvUnit1Save.ValidationGroup == strValidationGroup)
        {
            rfvUnit1Save.Validate();
            if (rfvUnit1Save.IsValid == false)
            {
                txtUnit1.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtUnit1.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtUnit1.ControlStyle.CssClass = "";
        }

        //Home No
        if (rfvUnit2Save.Enabled && rfvUnit2Save.ValidationGroup == strValidationGroup)
        {
            rfvUnit2Save.Validate();
            if (rfvUnit2Save.IsValid == false)
            {
                txtUnit2.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtUnit2.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtUnit2.ControlStyle.CssClass = "";
        }

        //Address
        if (rfvAddressSave.Enabled && rfvAddressSave.ValidationGroup == strValidationGroup)
        {
            rfvAddressSave.Validate();
            if (rfvAddressSave.IsValid == false)
            {
                txtAddress.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtAddress.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtAddress.ControlStyle.CssClass = "";
        }

        //Applicant's Mobile Number
        txtMobileNo.ChangeValidationEffectServerSide(strValidationGroup);
        txtOfficePhoneNo.ChangeValidationEffectServerSide(strValidationGroup);

        if (revEmpNameSave.Enabled && revEmpNameSave.ValidationGroup == strValidationGroup)
        {
            //if (rfvEmpName.IsValid)
            //{
            revEmpNameSave.Validate();
            if (revEmpNameSave.IsValid == false)
            {
                txtEmpName.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtEmpName.ControlStyle.CssClass = "";
            }
            //}
        }
        else
        {
            txtEmpName.ControlStyle.CssClass = "";
        }

        //Applicant's Nationality
        ddlNationality.ChangeValidationEffectServerSide(strValidationGroup);

        //Applicant's Id Number
        ddlIdNumber.ChangeValidationEffectServerSide(strValidationGroup);

        #endregion

        #region Vechicle Details
        //NCD Reason
        if (rfvNCDReasonSave.Enabled && rfvNCDReasonSave.ValidationGroup == strValidationGroup)
        {
            rfvNCDReasonSave.Validate();
            if (rfvNCDReasonSave.IsValid == false)
            {
                txtNCDReason.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtNCDReason.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtNCDReason.ControlStyle.CssClass = "";
        }

        //VehicleNo
        if (rfvVehicleNoSave.Enabled && rfvVehicleNoSave.ValidationGroup == strValidationGroup)
        {
            rfvVehicleNoSave.Validate();
            if (rfvVehicleNoSave.IsValid == false)
            {
                txtVehicleNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtVehicleNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtVehicleNo.ControlStyle.CssClass = "";
        }

        //Date Of Registeration
        ddlDORegisteration.ChangeValidationEffectServerSide(strValidationGroup);

        //EngineNo
        if (rfvEngineNoSave.Enabled && rfvEngineNoSave.ValidationGroup == strValidationGroup)
        {
            rfvEngineNoSave.Validate();
            if (rfvEngineNoSave.IsValid == false)
            {
                txtEngineNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtEngineNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtEngineNo.ControlStyle.CssClass = "";
        }

        //ChassisNo
        if (rfvChassisNoSave.Enabled && rfvChassisNoSave.ValidationGroup == strValidationGroup)
        {
            rfvChassisNoSave.Validate();
            if (rfvChassisNoSave.IsValid == false)
            {
                txtChassisNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtChassisNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtChassisNo.ControlStyle.CssClass = "";
        }

        //Insurance Company
        if (rfvCurInsuranceCompanySave.Enabled && rfvCurInsuranceCompanySave.ValidationGroup == strValidationGroup)
        {
            rfvCurInsuranceCompanySave.Validate();
            if (rfvCurInsuranceCompanySave.IsValid == false)
            {
                ddlCurInsuranceCompany.ControlStyle.CssClass = "validationError";
            }
            else
            {
                ddlCurInsuranceCompany.ControlStyle.CssClass = "";
            }
        }
        else
        {
            ddlCurInsuranceCompany.ControlStyle.CssClass = "";
        }
        //Insurance Vechicle No
        if (rfvInsVehicleNoSave.Enabled && rfvInsVehicleNoSave.ValidationGroup == strValidationGroup)
        {
            rfvInsVehicleNoSave.Validate();
            if (rfvInsVehicleNoSave.IsValid == false)
            {
                txtInsVehicleNo.ControlStyle.CssClass = "validationError";
            }
            else
            {
                txtInsVehicleNo.ControlStyle.CssClass = "";
            }
        }
        else
        {
            txtInsVehicleNo.ControlStyle.CssClass = "";
        }

        //Insurance Date Of Cancellation
        ddlDOCancellation.ChangeValidationEffectServerSide(strValidationGroup);
        //Insurance NCD

        #endregion
    }

    protected void CheckDriverSalGenderValid1(object sender, ServerValidateEventArgs args)
    {
        string _sal = ddlDriverSalutation1.GetSalutation();
        string _gender = ddlDriverGender1.GetGender();
        if (_gender == "M")
        {
            if (_sal == "Ms" || _sal == "Miss" || _sal == "Mdm" || _sal == "Mrs")
            {
                args.IsValid = false;
            }
        }
        else if (_gender == "F")
        {
            if (_sal == "Mr")
            {
                args.IsValid = false;
            }
        }
        else
        {
            args.IsValid = true;
        }
    }

    protected void CheckDriverSalGenderValid2(object sender, ServerValidateEventArgs args)
    {
        string _sal = ddlDriverSalutation2.GetSalutation();
        string _gender = ddlDriverGender2.GetGender();
        if (_gender == "M")
        {
            if (_sal == "Ms" || _sal == "Miss" || _sal == "Mdm" || _sal == "Mrs")
            {
                args.IsValid = false;
            }
        }
        else if (_gender == "F")
        {
            if (_sal == "Mr")
            {
                args.IsValid = false;
            }
        }
        else
        {
            args.IsValid = true;
        }
    }

    protected void CheckDriverSalGenderValid3(object sender, ServerValidateEventArgs args)
    {
        string _sal = ddlDriverSalutation3.GetSalutation();
        string _gender = ddlDriverGender3.GetGender();
        if (_gender == "M")
        {
            if (_sal == "Ms" || _sal == "Miss" || _sal == "Mdm" || _sal == "Mrs")
            {
                args.IsValid = false;
            }
        }
        else if (_gender == "F")
        {
            if (_sal == "Mr")
            {
                args.IsValid = false;
            }
        }
        else
        {
            args.IsValid = true;
        }
    }

    protected void CheckDriverSalGenderValid4(object sender, ServerValidateEventArgs args)
    {
        string _sal = ddlDriverSalutation4.GetSalutation();
        string _gender = ddlDriverGender4.GetGender();
        if (_gender == "M")
        {
            if (_sal == "Ms" || _sal == "Miss" || _sal == "Mdm" || _sal == "Mrs")
            {
                args.IsValid = false;
            }
        }
        else if (_gender == "F")
        {
            if (_sal == "Mr")
            {
                args.IsValid = false;
            }
        }
        else
        {
            args.IsValid = true;
        }
    }

    protected void CheckDriverSalGenderValid5(object sender, ServerValidateEventArgs args)
    {
        string _sal = ddlDriverSalutation5.GetSalutation();
        string _gender = ddlDriverGender5.GetGender();
        if (_gender == "M")
        {
            if (_sal == "Ms" || _sal == "Miss" || _sal == "Mdm" || _sal == "Mrs")
            {
                args.IsValid = false;
            }
        }
        else if (_gender == "F")
        {
            if (_sal == "Mr")
            {
                args.IsValid = false;
            }
        }
        else
        {
            args.IsValid = true;
        }
    }

    private void EnableDriverPanels()
    {
        if (txtDriverCount.Text.Trim() == "0")
        {
            pnlDriverDetails.Visible = false;
            pnlDriver1.Visible = false;
            pnlDriver2.Visible = false;
            pnlDriver3.Visible = false;
            pnlDriver4.Visible = false;
            pnlDriver5.Visible = false;

            ValidateDriver1(false);
            ValidateDriver2(false);
            ValidateDriver3(false);
            ValidateDriver4(false);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "1")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = false;
            pnlDriver3.Visible = false;
            pnlDriver4.Visible = false;
            pnlDriver5.Visible = false;

            ValidateDriver1(true);
            ValidateDriver2(false);
            ValidateDriver3(false);
            ValidateDriver4(false);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "2")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = true;
            pnlDriver3.Visible = false;
            pnlDriver4.Visible = false;
            pnlDriver5.Visible = false;

            ValidateDriver1(true);
            ValidateDriver2(true);
            ValidateDriver3(false);
            ValidateDriver4(false);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "3")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = true;
            pnlDriver3.Visible = true;
            pnlDriver4.Visible = false;
            pnlDriver5.Visible = false;

            ValidateDriver1(true);
            ValidateDriver2(true);
            ValidateDriver3(true);
            ValidateDriver4(false);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "4")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = true;
            pnlDriver3.Visible = true;
            pnlDriver4.Visible = true;
            pnlDriver5.Visible = false;

            ValidateDriver1(true);
            ValidateDriver2(true);
            ValidateDriver3(true);
            ValidateDriver4(true);
            ValidateDriver5(false);
        }
        else if (txtDriverCount.Text.Trim() == "5")
        {
            pnlDriverDetails.Visible = true;
            pnlDriver1.Visible = true;
            pnlDriver2.Visible = true;
            pnlDriver3.Visible = true;
            pnlDriver4.Visible = true;
            pnlDriver5.Visible = true;

            ValidateDriver1(true);
            ValidateDriver2(true);
            ValidateDriver3(true);
            ValidateDriver4(true);
            ValidateDriver5(true);
        }
    }

    private void ValidateDriver1(bool OnOff)
    {
        rfvDriverSurName1.Enabled = OnOff;
        ddlDriverSalutation1.IsEnableValidation(OnOff);
        ddlDriverGender1.IsEnableValidation(OnOff);
        ddlDriverIdType1.IsEnableValidation(OnOff);
        ddlDriverIdNumber1.IsEnableValidation(OnOff);
        csvDriverSalGender1.Enabled = OnOff;
    }

    private void ValidateDriver2(bool OnOff)
    {
        rfvDriverSurName2.Enabled = OnOff;
        ddlDriverSalutation2.IsEnableValidation(OnOff);
        ddlDriverGender2.IsEnableValidation(OnOff);
        ddlDriverIdType2.IsEnableValidation(OnOff);
        ddlDriverIdNumber2.IsEnableValidation(OnOff);
        csvDriverSalGender2.Enabled = OnOff;
    }

    private void ValidateDriver3(bool OnOff)
    {
        rfvDriverSurName3.Enabled = OnOff;
        ddlDriverSalutation3.IsEnableValidation(OnOff);
        ddlDriverGender3.IsEnableValidation(OnOff);
        ddlDriverIdType3.IsEnableValidation(OnOff);
        ddlDriverIdNumber3.IsEnableValidation(OnOff);
        csvDriverSalGender3.Enabled = OnOff;
    }

    private void ValidateDriver4(bool OnOff)
    {
        rfvDriverSurName4.Enabled = OnOff;
        ddlDriverSalutation4.IsEnableValidation(OnOff);
        ddlDriverGender4.IsEnableValidation(OnOff);
        ddlDriverIdType4.IsEnableValidation(OnOff);
        ddlDriverIdNumber4.IsEnableValidation(OnOff);
        csvDriverSalGender4.Enabled = OnOff;
    }

    private void ValidateDriver5(bool OnOff)
    {
        rfvDriverSurName5.Enabled = OnOff;
        ddlDriverSalutation5.IsEnableValidation(OnOff);
        ddlDriverGender5.IsEnableValidation(OnOff);
        ddlDriverIdType5.IsEnableValidation(OnOff);
        ddlDriverIdNumber5.IsEnableValidation(OnOff);
        csvDriverSalGender5.Enabled = OnOff;
    }

    protected void csvCreditCardValid_ServerValidate(object source, ServerValidateEventArgs args)
    {
        bool _status = true;
        if (rdoCreditCard.Checked)
        {
            string _first = txtCardNo1.Text.Trim().Substring(0, 1);
            if (rdoVisa.Checked)
            {
                if (_first != "4")
                {
                    _status = false;
                }
            }
            else if (rdoMasterCard.Checked)
            {
                if (_first != "5")
                {
                    _status = false;
                }
            }
            if (_status == true)
            {
                txtCreditCardValid.Text = "";
                txtCreditCardValid.Text = txtCardNo1.Text.Trim() + "" + txtCardNo2.Text.Trim() + "" + txtCardNo3.Text.Trim() + "" + txtCardNo4.Text.Trim();
                string _cardNumer = txtCreditCardValid.Text;
                MySecurity _mysecurity = new MySecurity();
                if (_mysecurity.IsCreditCardValid(_cardNumer))
                {
                    args.IsValid = true;
                }
                else
                {
                    args.IsValid = false;
                }
            }
            else
            {
                args.IsValid = false;
            }
        }
        else
        {
            txtCreditCardValid.Text = "Valid";
        }
    }

    protected void csvCCExpiredValid_ServerValidate(object source, ServerValidateEventArgs args)
    {
        txtCCExpiredValid.Text = "";
        txtCCExpiredValid.Text = "valid";
        if (rdoCreditCard.Checked)
        {
            Int32 _Year = Convert.ToInt32(ddlCardExpiryYear.Text);
            Int32 _Month = Convert.ToInt32(ddlCardExpiryMonth.Text);

            MySecurity _mysecurity = new MySecurity();
            if (_mysecurity.IsCreditCardExpiredDateValid(_Year, _Month))
            {
                args.IsValid = true;
            }
            else
            {
                args.IsValid = false;
            }
            //bool _status = true;
            //string _first = txtCardNo1.Text.Trim().Substring(0, 1);
            //if (rdoVisa.Checked)
            //{
            //    if (_first != "4")
            //    {
            //        _status = false;
            //    }
            //}
            //else if (rdoMasterCard.Checked)
            //{
            //    if (_first != "5")
            //    {
            //        _status = false;
            //    }
            //}
            //if (_status == true)
            //{
            //    txtCCExpiredValid.Text = "";
            //    txtCreditCardValid.Text = "valid";

            //    Int32 _Year = Convert.ToInt32(ddlCardExpiryYear.Text);
            //    Int32 _Month = Convert.ToInt32(ddlCardExpiryMonth.Text);
            //    if (ValidExpiredDate(_Year, _Month))
            //    {
            //        args.IsValid = true;
            //    }
            //    else
            //    {
            //        args.IsValid = false;
            //    }
            //}
            //else
            //{
            //    args.IsValid = false;
            //}
        }
    }

    protected void csvVehicleNoValid_ServerValidate(object source, ServerValidateEventArgs args)
    {
        txtVehicleNoValid.Text = "";
        txtVehicleNoValid.Text = "valid";
        string _VehicleNo = txtVehicleNo.Text.Trim();
        string _FirstLetter = _VehicleNo.Substring(0, 1);
        string _blockVal = CE.Configuration.MyConfigurationManager.GetAppSettingValue("BlockedVehicleChar");
        string[] _BlockedVehicleChar = _blockVal.Split(',');
        args.IsValid = true;
        for (int i = 0; i < _BlockedVehicleChar.Length; i++)
        {
            if (_FirstLetter.ToUpper() == _BlockedVehicleChar[i].ToString())
            {
                args.IsValid = false;
            }
        }
    }

    protected void csvInsVehicleNoValid_ServerValidate(object source, ServerValidateEventArgs args)
    {
        if (ddlCurInsuranceCompany.Text != "177")
        {
            txtInsVehicleNoValid.Text = "";
            txtInsVehicleNoValid.Text = "valid";
            string _VehicleNo = txtInsVehicleNo.Text.Trim();
            string _FirstLetter = _VehicleNo.Substring(0, 1);
            string _blockVal = CE.Configuration.MyConfigurationManager.GetAppSettingValue("BlockedVehicleChar");
            string[] _BlockedVehicleChar = _blockVal.Split(',');
            args.IsValid = true;
            for (int i = 0; i < _BlockedVehicleChar.Length; i++)
            {
                if (_FirstLetter.ToUpper() == _BlockedVehicleChar[i].ToString())
                {
                    args.IsValid = false;
                }
            }
        }
        else
        {
            args.IsValid = true;
        }
    }

    protected void GetNCDProtection()
    {
        //if ((inputNCD.Value == "30" || inputNCD.Value == "40" || inputNCD.Value == "50") && lblAnyclaim.Text == "No")
        if (inputNCD.Value == "30" || inputNCD.Value == "40" || inputNCD.Value == "50")
        {
            lblPremiumBeforeNCDPro.Text = lblPremiums.Text;

            MyDatabase _db = new MyDatabase();
            DataTable _dtResult = new DataTable();

            string _spName = "[sprocCarInsuranceTempResultSelectItemSelectSingleItem]";

            if (lblCarId.Text != string.Empty && lblCarResultId.Text != string.Empty
                && lblCustomerId.Text != string.Empty && lblProviderCompanyId.Text != string.Empty)
            {
                _CarId = Convert.ToInt64(lblCarId.Text);
                _CXCTypeId = Convert.ToInt64(lblCarResultId.Text);
                _UserId = Convert.ToInt64(lblCustomerId.Text);
                _ProviderId = Convert.ToInt64(lblProviderCompanyId.Text);
            }
            else if (Session[General.CarId] != null && Session[General.UserId] != null
                && Session[General.ProviderCompanyId] != null && Session[General.CarResultId] != null)
            {
                _CarId = Convert.ToInt64(Session[General.CarId].ToString());
                _CXCTypeId = Convert.ToInt64(Session[General.CarResultId].ToString());
                _UserId = Convert.ToInt64(Session[General.UserId].ToString());
                _ProviderId = Convert.ToInt64(Session[General.ProviderCompanyId].ToString());
            }

            SortedList _sPara = new SortedList();
            _sPara.Add("@CECarId", _CarId);
            _sPara.Add("@CarResultId", _CXCTypeId);
            _sPara.Add("@RefCEUserId", _UserId);
            _sPara.Add("@ProviderCompanyId", _ProviderId);

            _dtResult = _db.GetDataTableBySP(_spName, _sPara);

            if (_dtResult.Rows.Count > 0)
            {
                double _annualPremium = Convert.ToDouble(_dtResult.Rows[0]["Finfo1"].ToString());
                double _monthlyPremium = _annualPremium / 12;
                _monthlyPremium = Math.Ceiling(_monthlyPremium);
                double _monthlyPremium6Months = _annualPremium / 6;
                _monthlyPremium6Months = Math.Ceiling(_monthlyPremium6Months);
                //lblPremiumAfterNCDPro.Text = String.Format("${0:f}", float.Parse(_dtResult.Rows[0]["Finfo1"].ToString())) + " (" + String.Format("${0:0,0.00}", _monthlyPremium) + " per month)";
                lblPremiumAfterNCDPro.Text = String.Format("${0:f}", float.Parse(_dtResult.Rows[0]["Finfo1"].ToString())) + "<br><small>6 months : " + String.Format("${0:0,0}", _monthlyPremium6Months) + " per month</small><br><small>12 months : " + String.Format("${0:0,0}", _monthlyPremium) + " per month</small>";
            }
        }
    }

    private bool CheckCarQuoteUpdateStatus()
    {
        bool _retValue = false;
        CarInsuranceCheckDB _carcheck = new CarInsuranceCheckDB();
        Int64 _checkResult = _carcheck.CheckUpdateStatus(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()), Convert.ToInt64(Session[General.CarResultId].ToString()), Convert.ToInt64(Session[General.UserId].ToString()), Convert.ToInt64(Session[General.CarId].ToString()));
        if (_checkResult > 0)
        {
            _retValue = true;
        }
        else
        {
            _retValue = false;
        }

        return _retValue;
    }

    protected void GenerateExcelProposalForm(Int64 RefID)
    {
        Label lblContent = new Label();
        string _fileName = "FileName";
        string _applicationdate = " : " + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "/" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "/" + CE.Global.General.GetUTCDateTime().Year + " " + CE.Global.General.GetUTCDateTime().ToShortTimeString();
        string convertno = General.GetRefNumber(RefID);
        _fileName = "L" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;

        StringBuilder strText = new StringBuilder("");
        strText.Append("<table><tr><td><h3>Liberty Insurance </h3></td><td></td><td colspan='2' align='right'> </td></tr></table>");

        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        _dsProposal = _proposaldownloaddb.GetLibertyProposal(RefID, "CI");
        string _html = "";

        if (_dsProposal.Tables[0].Rows.Count > 0)
        {
            #region variables
            string _name, _unitno, _homeno, _address, _postalcode, _dob, _dd, _mm, _yy, _nationality, _nric, _maritalstatus, _officeno, _mobile;
            string _gender, _expdriving, _vehicleno, _make, _model, _vehicletype, _engineno, _chassisno, _cc, _regyear, _mfgyear, _hpstatus, _hpcomp;
            string _insstartdate, _insenddate, _isdd, _ismm, _isyy, _iedd, _iemm, _ieyy, _insstatus, _inscomp, _insvhleno, _insncdentitle;
            string _inspldate, _indd, _inmm, _inyy, _ncdreson, _bodytype, _occupation, _empname, _drwestmylsa, _vhlemodifystatus, _vhlemodifyreason;
            string _drname1, _drage1, _drgender1, _drmarital1, _drocc1, _drexp1, _drname2, _drage2, _drgender2, _drmarital2, _drocc2, _drexp2;
            string _drname3, _drage3, _drgender3, _drmarital3, _drocc3, _drexp3, _drname4, _drage4, _drgender4, _drmarital4, _drocc4, _drexp4;
            string _drname5, _drage5, _drgender5, _drmarital5, _drocc5, _drexp5, _demeritstatus, _demeritcount, _dmdrname1, _dmdrpoint1;
            string _drDOB1, _drDOB2, _drDOB3, _drDOB4, _drDOB5;
            string _dmdrdate1, _dmdrtype1, _dmdrname2, _dmdrpoint2, _dmdrdate2, _dmdrtype2, _dmdrname3, _dmdrpoint3, _dmdrdate3, _dmdrtype3;
            string _dmdrname4, _dmdrpoint4, _dmdrdate4, _dmdrtype4, _dmdrname5, _dmdrpoint5, _dmdrdate5, _dmdrtype5, _dmdrname6, _dmdrpoint6;
            string _dmdrdate6, _dmdrtype6, _adddriver, _drcount, _installmenttype, _nameofcard, _issuebank, _ccno, _cno, _ccexmm, _ccexyy, _cctype, _claimstatus, _claim1ststat, _claim1stend;
            string _claimcount1, claimamt1, _claim2ndstat, _claim2ndend, claimamt2, _claim3rdstat, _claim3rdend, claimamt3, _ncdstatus, _ncdpercent, _ncdnil;
            string _inscancelstatus, _cancelreason, _impairstatus, _impairreason, _accessorystatus, _accessorydetail, _convictedstatus, _convictedreason, _planname, _annualpremium;
            string _insrefusedstatus, _refusedreason, _jobnature, _email;
            string _drjobnature1, _drjobnature2, _drjobnature3, _drjobnature4, _drjobnature5;

            DateTime _dofb, _isdate, _iedate, _indate;

            _email = "";
            _jobnature = ""; _drjobnature1 = ""; _drjobnature2 = ""; _drjobnature3 = ""; _drjobnature4 = ""; _drjobnature5 = "";
            _inscancelstatus = ""; _cancelreason = ""; _impairstatus = ""; _impairreason = ""; _demeritstatus = ""; _demeritcount = "";
            _dmdrname1 = ""; _dmdrpoint1 = ""; _dmdrdate1 = ""; _dmdrtype1 = ""; _dmdrname2 = ""; _dmdrpoint2 = ""; _dmdrdate2 = ""; _dmdrtype2 = "";
            _dmdrname3 = ""; _dmdrpoint3 = ""; _dmdrdate3 = ""; _dmdrtype3 = ""; _dmdrname4 = ""; _dmdrdate4 = ""; _dmdrtype4 = "";
            _dmdrpoint4 = ""; _dmdrname5 = ""; _dmdrpoint5 = ""; _dmdrdate5 = ""; _dmdrtype5 = ""; _dmdrname6 = "";
            _dmdrpoint6 = ""; _dmdrdate6 = ""; _dmdrtype6 = ""; _vehicletype = ""; _expdriving = "";
            _drname1 = ""; _drage1 = ""; _drgender1 = ""; _drmarital1 = ""; _drocc1 = ""; _drexp1 = "";
            _drname2 = ""; _drage2 = ""; _drgender2 = ""; _drmarital2 = ""; _drocc2 = ""; _drexp2 = "";
            _drname3 = ""; _drage3 = ""; _drgender3 = ""; _drmarital3 = ""; _drocc3 = ""; _drexp3 = "";
            _drname4 = ""; _drage4 = ""; _drgender4 = ""; _drmarital4 = ""; _drocc4 = ""; _drexp4 = "";
            _drname5 = ""; _drage5 = ""; _drgender5 = ""; _drmarital5 = ""; _drocc5 = ""; _drexp5 = ""; _planname = ""; _annualpremium = "";
            _adddriver = ""; _drcount = ""; _installmenttype = ""; _nameofcard = ""; _issuebank = ""; _ccno = ""; _ccexmm = ""; _ccexyy = ""; _cctype = "";
            _insrefusedstatus = ""; _refusedreason = "";
            _drDOB1 = ""; _drDOB2 = ""; _drDOB3 = ""; _drDOB4 = ""; _drDOB5 = "";

            _name = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
            _dofb = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["DOB"].ToString());
            _dd = _dofb.Day.ToString("00");
            _mm = _dofb.Month.ToString("00");
            _yy = _dofb.Year.ToString();
            //_dob = _dd + "/" + _mm + "/" + _yy;
            _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
            _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
            _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
            _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
            _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
            _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
            _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
            _maritalstatus = _dsProposal.Tables[0].Rows[0]["Marital"].ToString();
            _gender = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
            _jobnature = _dsProposal.Tables[0].Rows[0]["NofBusi"].ToString();
            _email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();

            _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
            _annualpremium = _dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString();

            _drwestmylsa = _dsProposal.Tables[0].Rows[0]["DrWMalaysia"].ToString();
            _expdriving = _dsProposal.Tables[0].Rows[0]["YearDriveSg"].ToString();
            _occupation = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
            _mobile = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
            _officeno = _dsProposal.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            _empname = _dsProposal.Tables[0].Rows[0]["EmpNameandTrade"].ToString();
            if (_dsProposal.Tables[0].Rows[0]["IsClaimLastThreeYear"].ToString() == "False")
            {
                _claimstatus = "No";
            }
            else
            {
                _claimstatus = "Yes";
            }
            if (_dsProposal.Tables[0].Rows[0]["HasPreInsurer"].ToString() == "True")
            {
                _insstatus = "Yes";
                if (_dsProposal.Tables[2].Rows.Count > 0)
                {
                    _inscomp = _dsProposal.Tables[2].Rows[0]["InsCompanyName"].ToString();
                    _insvhleno = _dsProposal.Tables[0].Rows[0]["PreInsVechicleNo"].ToString();
                    _indate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["PreInsExpiryDate"].ToString());
                    _indd = _indate.Day.ToString("00");
                    _inmm = _indate.Month.ToString("00");
                    _inyy = _indate.Year.ToString();
                    //_inspldate = _dd + "/" + _mm + "/" + _yy;
                    _inspldate = _dsProposal.Tables[0].Rows[0]["PreInsExpiryDate"].ToString();
                    if (_dsProposal.Tables[0].Rows[0]["NCDEntitlement"].ToString() == "-1")
                    {
                        _insncdentitle = "";
                    }
                    else
                    {
                        _insncdentitle = _dsProposal.Tables[0].Rows[0]["NCDEntitlement"].ToString() + "%";
                    }
                }
                else
                {
                    _insstatus = "No";
                    _inscomp = "";
                    _insvhleno = "";
                    _inspldate = "";
                    _insncdentitle = "";
                }
            }
            else
            {
                _insstatus = "No";
                _inscomp = "";
                _insvhleno = "";
                _inspldate = "";
                _insncdentitle = "";
            }

            _ncdpercent = _dsProposal.Tables[0].Rows[0]["NCDPercent"].ToString();
            if (_ncdpercent.ToString() == "-1")
            {
                _ncdpercent = "No NCD(First Policy)";
            }
            else
            {
                _ncdpercent += "%";
            }
            _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDReason"].ToString();
            if (_ncdreson == "Others")
            {
                _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDOtherReason"].ToString();
            }
            else if (_ncdreson == "-1")
            {
                _ncdreson = "";
            }
            if (_dsProposal.Tables[1].Rows.Count > 0)
            {
                _claim1ststat = _dsProposal.Tables[1].Rows[0]["Claim1stStartDate"].ToString();
                _claim1stend = _dsProposal.Tables[1].Rows[0]["Claim1stEndDate"].ToString();
                claimamt1 = _dsProposal.Tables[1].Rows[0]["NOCLast1Value"].ToString();
                _claimcount1 = _dsProposal.Tables[1].Rows[0]["NOCLast1"].ToString();

                _claim2ndstat = _dsProposal.Tables[1].Rows[0]["Claim2ndStartDate"].ToString();
                _claim2ndend = _dsProposal.Tables[1].Rows[0]["Claim2ndEndDate"].ToString();
                claimamt2 = _dsProposal.Tables[1].Rows[0]["NOCLast2Value"].ToString();

                _claim3rdstat = _dsProposal.Tables[1].Rows[0]["Claim3rdStartDate"].ToString();
                _claim3rdend = _dsProposal.Tables[1].Rows[0]["Claim3rdEndDate"].ToString();
                claimamt3 = _dsProposal.Tables[1].Rows[0]["NOCLast3Value"].ToString();
            }
            else
            {
                _claim1ststat = "";
                _claim1stend = "";
                claimamt1 = "";
                _claimcount1 = "0";

                _claim2ndstat = "";
                _claim2ndend = "";
                claimamt2 = "";

                _claim3rdstat = "";
                _claim3rdend = "";
                claimamt3 = "";
                _claimstatus = "No";
                _ncdpercent = "0%";
            }
            _ncdpercent = _dsProposal.Tables[0].Rows[0]["NCDPercent"].ToString();
            if (_ncdpercent.ToString() == "-1")
            {
                _ncdpercent = "10%";
            }
            else
            {
                if (_claimstatus == "No")
                {
                    _ncdpercent = NoNCD(_ncdpercent);
                }
                else if (_claimstatus == "Yes" && _claimcount1 == "0")
                {
                    _ncdpercent = NoNCD(_ncdpercent);
                }
                else if (_claimstatus == "Yes" && _claimcount1 == "1")
                {
                    _ncdpercent = OneTimesNCD(_ncdpercent);
                }
                else
                {
                    _ncdpercent = "0%";
                }
            }
            if (_dsProposal.Tables[0].Rows[0]["HasVechicleModified"].ToString() == "True")
            {
                _vhlemodifystatus = "Yes";
                _vhlemodifyreason = _dsProposal.Tables[0].Rows[0]["VechicleModifyReason"].ToString();
            }
            else
            {
                _vhlemodifystatus = "No";
                _vhlemodifyreason = "";
            }
            if (_dsProposal.Tables[0].Rows[0]["HasInsuranceTerminated"].ToString() == "True")
            {
                _inscancelstatus = "Yes";
                _cancelreason = _dsProposal.Tables[0].Rows[0]["InsuranceTerminatedReason"].ToString();
            }
            else
            {
                _inscancelstatus = "No";
                _cancelreason = "";
            }

            if (_dsProposal.Tables[0].Rows[0]["HasPhysicalImpairment"].ToString() == "True")
            {
                _impairstatus = "Yes";
                _impairreason = _dsProposal.Tables[0].Rows[0]["PhysicalImpairmentReason"].ToString();
            }
            else
            {
                _impairstatus = "No";
                _impairreason = "";
            }
            if (_dsProposal.Tables[0].Rows[0]["HasConvictedMoterOffence"].ToString() == "True")
            {
                _convictedstatus = "Yes";
                _convictedreason = _dsProposal.Tables[0].Rows[0]["ConvictedReason"].ToString();
            }
            else
            {
                _convictedstatus = "No";
                _convictedreason = "";
            }
            if (_dsProposal.Tables[0].Rows[0]["HasAccessory"].ToString() == "True")
            {
                _accessorystatus = "Yes";
                _accessorydetail = _dsProposal.Tables[0].Rows[0]["AccessoryDescription"].ToString();
            }
            else
            {
                _accessorystatus = "No";
                _accessorydetail = "";
            }


            if (_dsProposal.Tables[0].Rows[0]["Info1"].ToString() == "1")
            {
                _insrefusedstatus = "Yes";
                _refusedreason = _dsProposal.Tables[0].Rows[0]["Info2"].ToString();
            }
            else
            {
                _insrefusedstatus = "No";
                _refusedreason = "";
            }

            if (_dsProposal.Tables[0].Rows[0]["HasDemeritPoints"].ToString() == "True")
            {
                if (_dsProposal.Tables[6].Rows.Count > 0)
                {
                    _demeritstatus = "Yes";
                    _demeritcount = _dsProposal.Tables[6].Rows.Count.ToString();

                    _dmdrname1 = _dsProposal.Tables[6].Rows[0]["DriverName"].ToString();
                    _dmdrpoint1 = _dsProposal.Tables[6].Rows[0]["TotalDemeritPoints"].ToString();
                    _dmdrdate1 = _dsProposal.Tables[6].Rows[0]["DemeritDate"].ToString();
                    _dmdrtype1 = _dsProposal.Tables[6].Rows[0]["TypeofOffence"].ToString();
                    if (_dsProposal.Tables[6].Rows.Count > 1)
                    {
                        _dmdrname2 = _dsProposal.Tables[6].Rows[1]["DriverName"].ToString();
                        _dmdrpoint2 = _dsProposal.Tables[6].Rows[1]["TotalDemeritPoints"].ToString();
                        _dmdrdate2 = _dsProposal.Tables[6].Rows[1]["DemeritDate"].ToString();
                        _dmdrtype2 = _dsProposal.Tables[6].Rows[1]["TypeofOffence"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 2)
                    {
                        _dmdrname3 = _dsProposal.Tables[6].Rows[2]["DriverName"].ToString();
                        _dmdrpoint3 = _dsProposal.Tables[6].Rows[2]["TotalDemeritPoints"].ToString();
                        _dmdrdate3 = _dsProposal.Tables[6].Rows[2]["DemeritDate"].ToString();
                        _dmdrtype3 = _dsProposal.Tables[6].Rows[2]["TypeofOffence"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 3)
                    {
                        _dmdrname4 = _dsProposal.Tables[6].Rows[3]["DriverName"].ToString();
                        _dmdrpoint4 = _dsProposal.Tables[6].Rows[3]["TotalDemeritPoints"].ToString();
                        _dmdrdate4 = _dsProposal.Tables[6].Rows[3]["DemeritDate"].ToString();
                        _dmdrtype4 = _dsProposal.Tables[6].Rows[3]["TypeofOffence"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 4)
                    {
                        _dmdrname5 = _dsProposal.Tables[6].Rows[4]["DriverName"].ToString();
                        _dmdrpoint5 = _dsProposal.Tables[6].Rows[4]["TotalDemeritPoints"].ToString();
                        _dmdrdate5 = _dsProposal.Tables[6].Rows[4]["DemeritDate"].ToString();
                        _dmdrtype5 = _dsProposal.Tables[6].Rows[4]["TypeofOffence"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 5)
                    {
                        _dmdrname6 = _dsProposal.Tables[6].Rows[5]["DriverName"].ToString();
                        _dmdrpoint6 = _dsProposal.Tables[6].Rows[5]["TotalDemeritPoints"].ToString();
                        _dmdrdate6 = _dsProposal.Tables[6].Rows[5]["DemeritDate"].ToString();
                        _dmdrtype6 = _dsProposal.Tables[6].Rows[5]["TypeofOffence"].ToString();
                    }
                }
                else
                {
                    _demeritstatus = "No";
                    _demeritcount = "0";
                }
            }
            else
            {
                _demeritstatus = "No";
                _demeritcount = "0";
            }

            _vehicleno = _dsProposal.Tables[0].Rows[0]["VechicleNo"].ToString();
            _mfgyear = _dsProposal.Tables[0].Rows[0]["ManufactYear"].ToString();
            _regyear = _dsProposal.Tables[0].Rows[0]["DateofReg"].ToString();
            _model = _dsProposal.Tables[5].Rows[0]["Description"].ToString();
            _make = _dsProposal.Tables[5].Rows[0]["Make"].ToString();
            _cc = _dsProposal.Tables[5].Rows[0]["CC"].ToString();
            _vehicletype = _dsProposal.Tables[5].Rows[0]["Body"].ToString();
            _engineno = _dsProposal.Tables[0].Rows[0]["EngineNo"].ToString();
            _chassisno = _dsProposal.Tables[0].Rows[0]["ChassisNo"].ToString();

            _isdate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["StartDate"].ToString());
            _isdd = _isdate.Day.ToString("00");
            _ismm = _isdate.Month.ToString("00");
            _isyy = _isdate.Year.ToString();
            //_insstartdate = _isdd + "/" + _ismm + "/" + _isyy;
            _insstartdate = _dsProposal.Tables[0].Rows[0]["StartDate"].ToString();

            _iedate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["EndDate"].ToString());
            _iedd = _iedate.Day.ToString("00");
            _iemm = _iedate.Month.ToString("00");
            _ieyy = _iedate.Year.ToString();
            //_insenddate = _iedd + "/" + _iemm + "/" + _ieyy;
            _insenddate = _dsProposal.Tables[0].Rows[0]["EndDate"].ToString();

            if (_dsProposal.Tables[3].Rows.Count > 0)
            {
                _hpstatus = "Yes";
                _hpcomp = _dsProposal.Tables[3].Rows[0]["HPCompanyName"].ToString();

                if (_hpcomp.ToString() == "")
                {
                    _hpcomp = "Not Applicable";
                }
            }
            else
            {
                _hpstatus = "No";
                _hpcomp = "Not Applicable";
            }
            if (_dsProposal.Tables[0].Rows[0]["AddDriver"].ToString() == "Yes")
            {
                _adddriver = "Yes";
                _drcount = _dsProposal.Tables[0].Rows[0]["NoOfDriver"].ToString();
            }
            else
            {
                _adddriver = "No";
                _drcount = "0";
            }
            if (_dsProposal.Tables[4].Rows.Count > 0)
            {
                if (Convert.ToInt16(_drcount) > 0)
                {
                    _drname1 = _dsProposal.Tables[4].Rows[0]["DriverName"].ToString();
                    _drage1 = _dsProposal.Tables[4].Rows[0]["Age"].ToString();
                    _drgender1 = _dsProposal.Tables[4].Rows[0]["Gender"].ToString();
                    _drmarital1 = _dsProposal.Tables[4].Rows[0]["Marital"].ToString();
                    _drocc1 = _dsProposal.Tables[4].Rows[0]["Description"].ToString();
                    _drexp1 = _dsProposal.Tables[4].Rows[0]["YearOfDrivingInSg"].ToString();
                    _drDOB1 = _dsProposal.Tables[4].Rows[0]["DOB"].ToString();
                    _drjobnature1 = _dsProposal.Tables[4].Rows[0]["JobNature"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 1)
                {
                    _drname2 = _dsProposal.Tables[4].Rows[1]["DriverName"].ToString();
                    _drage2 = _dsProposal.Tables[4].Rows[1]["Age"].ToString();
                    _drgender2 = _dsProposal.Tables[4].Rows[1]["Gender"].ToString();
                    _drmarital2 = _dsProposal.Tables[4].Rows[1]["Marital"].ToString();
                    _drocc2 = _dsProposal.Tables[4].Rows[1]["Description"].ToString();
                    _drexp2 = _dsProposal.Tables[4].Rows[1]["YearOfDrivingInSg"].ToString();
                    _drDOB2 = _dsProposal.Tables[4].Rows[1]["DOB"].ToString();
                    _drjobnature2 = _dsProposal.Tables[4].Rows[1]["JobNature"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 2)
                {
                    _drname3 = _dsProposal.Tables[4].Rows[2]["DriverName"].ToString();
                    _drage3 = _dsProposal.Tables[4].Rows[2]["Age"].ToString();
                    _drgender3 = _dsProposal.Tables[4].Rows[2]["Gender"].ToString();
                    _drmarital3 = _dsProposal.Tables[4].Rows[2]["Marital"].ToString();
                    _drocc3 = _dsProposal.Tables[4].Rows[2]["Description"].ToString();
                    _drexp3 = _dsProposal.Tables[4].Rows[2]["YearOfDrivingInSg"].ToString();
                    _drDOB3 = _dsProposal.Tables[4].Rows[2]["DOB"].ToString();
                    _drjobnature3 = _dsProposal.Tables[4].Rows[2]["JobNature"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 3)
                {
                    _drname4 = _dsProposal.Tables[4].Rows[3]["DriverName"].ToString();
                    _drage4 = _dsProposal.Tables[4].Rows[3]["Age"].ToString();
                    _drgender4 = _dsProposal.Tables[4].Rows[3]["Gender"].ToString();
                    _drmarital4 = _dsProposal.Tables[4].Rows[3]["Marital"].ToString();
                    _drocc4 = _dsProposal.Tables[4].Rows[3]["Description"].ToString();
                    _drexp4 = _dsProposal.Tables[4].Rows[3]["YearOfDrivingInSg"].ToString();
                    _drDOB4 = _dsProposal.Tables[4].Rows[3]["DOB"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 4)
                {
                    _drname5 = _dsProposal.Tables[4].Rows[4]["DriverName"].ToString();
                    _drage5 = _dsProposal.Tables[4].Rows[4]["Age"].ToString();
                    _drgender5 = _dsProposal.Tables[4].Rows[4]["Gender"].ToString();
                    _drmarital5 = _dsProposal.Tables[4].Rows[4]["Marital"].ToString();
                    _drocc5 = _dsProposal.Tables[4].Rows[4]["Description"].ToString();
                    _drexp5 = _dsProposal.Tables[4].Rows[4]["YearOfDrivingInSg"].ToString();
                    _drDOB5 = _dsProposal.Tables[4].Rows[4]["DOB"].ToString();
                    _drjobnature5 = _dsProposal.Tables[4].Rows[4]["JobNature"].ToString();
                }
            }

            DataSet _dsPayment = new DataSet();
            _dsPayment = _proposaldownloaddb.GetPaymentDetails(RefID, 29, "CI");
            if (_dsPayment != null && _dsPayment.Tables[0].Rows.Count > 0)
            {
                _nameofcard = _dsPayment.Tables[0].Rows[0]["NameoftheCard"].ToString();
                _issuebank = _dsPayment.Tables[0].Rows[0]["IssuingBankName"].ToString();
                _cno = _dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString();
                _ccexmm = _dsPayment.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
                _ccexyy = _dsPayment.Tables[0].Rows[0]["CardExpiryYear"].ToString();
                _cctype = _dsPayment.Tables[0].Rows[0]["CardType"].ToString();
                _installmenttype = _dsPayment.Tables[0].Rows[0]["Installment"].ToString();
                if (_dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString() != "")
                    _ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);
                else
                    _ccno = "";
            }

            #endregion

            //_html = "<table><tr><td width='25%'>Plan Name</td><td>" + _planname + "</td><td colspan='2' align='right'>Annual Premium : $" + _annualpremium.ToString() + "</td></tr></table>";
            _html = "<table><tr><td colspan='4'> </td></tr></table>";
            _html += "<table><tr><td colspan='4' align='center'><b>MOTOR INSURANCE PROPOSAL</b></td></tr></table>";

            _html += "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                     + "<tr>"
                     + "<td width='50%'>" //Start 1
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                     + "<tr>"
                     + "<td width='50%' align='left'><b>Reference Number</b> </td>"
                     + "<td width='50%' align='left'>" + "L" + convertno.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan='2'><b>Insured's Particulars</b></td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>IC/ROC Number</td>"
                     + "<td width='50%' align='left'>" + _nric.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td align='left' >Address</td>"
                     + "<td align='left'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0'>"
                     + "<tr><td align='left'>#" + _unitno.ToString() + " - " + _homeno.ToString() + "</td></tr>"
                     + "<tr><td align='left'>" + _address.ToString() + "</td></tr>"
                     + "<tr><td align='left'>Postal Code " + _postalcode.ToString() + "</td></tr>"
                     + "</table>"
                     + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan='2'> </td>"
                     + "</tr>"

                     + "</table>"
                     + "</td>" //End 1

                     + "<td width='50%'>" //Start 2
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"


                     + "<tr>"
                     + "<td width='50%' align='left'>Date</td>"
                     + "<td width='50%' align='left'>" + CE.Global.General.GetUTCDateTime().ToString("dd-mm-yyyy") + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan='2'> </td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left'>Name</td>"
                     + "<td width='50%' align='left'>" + _name.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan='2'> </td>"
                     + "</tr>"
                     + "<tr>"
                     + "<td colspan='2'> </td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td width='50%' align='left' >Mobile No./Office No.</td>"
                     + "<td width='50%' align='left' >" + _mobile.ToString() + " / " + _officeno.ToString() + "</td>"
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan='2'> </td>"
                     + "</tr>"


                     //+ "<tr>"
                //+ "<td width='50%' align='left'>Nationality</td>"
                //+ "<td width='50%' align='left'>" + _nationality.ToString() + "</td>"
                //+ "</tr>"


                     + "</table>"
                     + "</td>" //End 2
                     + "</tr>"

                     + "<tr>"
                     + "<td colspan='2'>"
                     + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"

                    + "<tr>"
                    + "<td width='50%' align='left'>Employer's Name & Trade </td>"
                    + "<td width='50%' align='left'>" + _empname.ToString() + "</td>"
                    + "<td width='50%' align='left'>Email Address</td>"
                     + "<td width='50%' align='left'>" + _email.ToString() + "</td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td colspan='4' align='left'> </td>"
                    + "</tr>"

                    + "<tr>"
                    + "<td colspan='4' align='left' width='100%'>"
                    + "<table style='width: 100%; background-color: white;' cellpadding='0' cellspacing='0' border='1'>"
                    + "<tr>"
                    + "<td align='center' width='16%'><b>Name</b></td>"
                    + "<td align='center' width='14%'><b>Sex</b></td>"
                    + "<td align='center' width='14%'><b>Date of Birth</b></td>"
                    + "<td align='center' width='14%'><b>Occupation</b></td>"
                    + "<td align='center' width='14%'><b>Indoor/Outdoor</b></td>"
                    + "<td align='center' width='14%'><b>Marital Status</b></td>"
                    + "<td align='center' width='14%'><b>Driving XP(Yrs)</b></td>"
                    + "</tr>"
                    + "<tr>"
                    + "<td align='center' width='16%'>" + _name.ToString() + "</td>"
                    + "<td align='center' width='14%'>" + _gender.ToString() + "</td>"
                    + "<td align='center' width='14%'>" + _dob.ToString() + "</td>"
                    + "<td align='center' width='14%'>" + _occupation.ToString() + "</td>"
                    + "<td align='center' width='14%'>" + _jobnature.ToString() + "</td>"
                    + "<td align='center' width='14%'>" + _maritalstatus.ToString() + "</td>"
                    + "<td align='center' width='14%'>" + _expdriving.ToString() + "</td>"
                    + "</tr>";

            for (int i = 1; i <= Convert.ToInt16(_drcount); i++)
            {
                if (i == 1)
                {
                    _html += "<tr>"
                    + "<td align='center' width='16%'>" + _drname1.ToString() + "</td>"
                    + "<td align='center' width='14%'>" + _drgender1.ToString() + "</td>"
                    + "<td align='center' width='14%'>" + _drDOB1.ToString() + "</td>"
                    + "<td align='center' width='14%'>" + _drocc1.ToString() + "</td>"
                    + "<td align='center' width='14%'>" + _drjobnature1.ToString() + "</td>"
                    + "<td align='center' width='14%'>" + _drmarital1.ToString() + "</td>"
                    + "<td align='center' width='14%'>" + _drexp1.ToString() + "</td>"
                    + "</tr>";
                }
                if (i == 2)
                {
                    _html += "<tr>"
                   + "<td align='center' width='16%'>" + _drname2.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drgender2.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drDOB2.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drocc2.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drjobnature2.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drmarital2.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drexp2.ToString() + "</td>"
                   + "</tr>";
                }

                if (i == 3)
                {
                    _html += "<tr>"
                   + "<td align='center' width='16%'>" + _drname3.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drgender3.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drDOB3.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drocc3.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drjobnature3.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drmarital3.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drexp3.ToString() + "</td>"
                   + "</tr>";
                }

                if (i == 4)
                {
                    _html += "<tr>"
                   + "<td align='center' width='16%'>" + _drname4.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drgender4.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drDOB4.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drocc4.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drjobnature4.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drmarital4.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drexp4.ToString() + "</td>"
                   + "</tr>";
                }

                if (i == 5)
                {
                    _html += "<tr>"
                   + "<td align='center' width='16%'>" + _drname5.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drgender5.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drDOB5.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drocc5.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drjobnature5.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drmarital5.ToString() + "</td>"
                   + "<td align='center' width='14%'>" + _drexp5.ToString() + "</td>"
                   + "</tr>";
                }

            }

            _html += "<tr>"
            + "<td align='center' width='16%'></td>"
            + "<td align='center' width='14%'></td>"
            + "<td align='center' width='14%'></td>"
            + "<td align='center' width='14%'></td>"
            + "<td align='center' width='14%'></td>"
            + "<td align='center width='14%''></td>"
            + "<td align='center' width='14%'></td>"
            + "</tr>"
            + "<tr>"
            + "<td colspan='7' align='center'></td>"
            + "</tr>"
            + "</table>"

            + "</td>"
            + "</tr>";


            //if (claimamt1.ToString() == "0")
            //{
            //    _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
            //    + "<td style='width:25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'> " + _claim1ststat.ToString() + " to " + _claim1stend.ToString() + "</td>"
            //    + "<td style='width: 25%' align='left'> Claim Amount</td>"
            //    + "<td style='width: 25%' align='left'>" + claimamt1.ToString() + "</td></tr>";
            //}
            //if (claimamt2.ToString() == "0")
            //{
            //    _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
            //    + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _claim2ndstat.ToString() + " to " + _claim2ndend.ToString() + "</td>"
            //    + "<td style='width: 25%' align='left'> Claim Amount</td>"
            //    + "<td style='width: 25%' align='left'>" + claimamt2.ToString() + "</td></tr>";
            //}
            //if (claimamt3.ToString() == "0")
            //{
            //    _html += "<tr><td style='width:25%' align='left'>Claim Date</td>"
            //    + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _claim3rdstat.ToString() + " to " + _claim3rdend.ToString() + "</td>"
            //    + "<td style='width: 25%' align='left'> Claim Amount</td>"
            //    + "<td style='width: 25%' align='left'>" + claimamt3.ToString() + "</td></tr>";
            //}

            //_html += "<tr><td style='width:25%' align='left'>NCD on next renewal (%)</td>"
            //+ "<td colspan='3' align='left'>" + _ncdpercent.ToString() + "</td></tr>";



            _html += "<tr><td colspan='4' align='left'><b>Vehicle Details</b></td></tr>"

             + "<tr><td style='width:25%' align='left'>Vehicle Number</td>"
             + "<td style='width: 25%' align='left'>" + _insvhleno.ToString() + "</td>"
             + "<td style='width: 25%' align='left'></td>"
             + "<td style='width: 25%' align='left'></td></tr>"

             + "<tr><td style='width:25%' align='left'>Chassis No</td>"
             + "<td style='width: 25%' align='left'>" + _chassisno.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Body Type</td>"
             + "<td style='width: 25%' align='left'>" + _vehicletype.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Engine No</td>"
             + "<td style='width: 25%' align='left'>" + _engineno.ToString() + "</td>"
             + "<td style='width: 25%' align='left'></td>"
             + "<td style='width: 25%' align='left'></td></tr>"

             + "<tr><td style='width:25%' align='left'>Make</td>"
             + "<td style='width: 25%' align='left'>" + _make.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Year of Manufacture</td>"
             + "<td style='width: 25%' align='left'>" + _mfgyear.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Model</td>"
             + "<td style='width: 25%' align='left'>" + _model.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Year of Registration</td>"
             + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _regyear.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Engine CC/Ton</td>"
             + "<td style='width: 25%' align='left'>" + _cc.ToString() + "</td>"
             + "<td style='width: 25%' align='left'></td>"
             + "<td style='width: 25%' align='left'></td></tr>"

             + "<tr><td colspan='4' align='left'><b></b></td></tr>"
             + "<tr><td colspan='4' align='left'><b>Claim Details</b></td></tr>"

             + "<tr><td style='width:25%' align='left'>Current Insurance Co.</td>"
             + "<td style='width: 25%' align='left'>" + _inscomp.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>Vehicle No.</td>"
             + "<td style='width: 25%' align='left'>" + _insvhleno.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Policy No</td>"
             + "<td style='width: 25%;></td>"
             + "<td style='width: 25%' align='left'>Expiry/Cancellation Date</td>"
                //+ "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _inspldate.ToString() + "</td></tr>"
             + "<td style='width: 25%; align='left'>" + _inspldate.ToString() + "</td></tr>"

             + "<tr><td style='width:25%' align='left'>Last 2 years claim XP</td>"
             + "<td style='width: 25%' align='left'>" + _claimstatus.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>No Claims in the last 2 Years</td>"
             + "<td style='width: 25%' align='left'></td></tr>"

             + "<tr><td style='width:25%' align='left'>NCD%</td>"
             + "<td style='width: 25%' align='left'>" + _insncdentitle.ToString() + "</td>"
             + "<td style='width: 25%' align='left'>OFD</td>"
             + "<td style='width: 25%' align='left'></td></tr>"

             + "<tr><td style='width:25%' align='left'>NCD Protector</td>"
             + "<td style='width: 25%' align='left'></td>"
             + "<td style='width: 25%' align='left'></td>"
             + "<td style='width: 25%' align='left'></td></tr>"

             + "<tr><td colspan='4' align='left'></td></tr>";

            //+ "<tr><td style='width:25%' align='left'>Any hire purchase to your motor vehicle?</td>"
            //+ "<td style='width: 25%' align='left'>" + _hpstatus.ToString() + "</td>"
            //+ "<td style='width: 25%' align='left'>Hire Purchase Company</td>"
            //+ "<td style='width: 25%' align='left'>" + _hpcomp.ToString() + "</td></tr>"

            // + "<tr><td colspan='4' align='left'>Do you have any motor vehicle Insurance? " + _insstatus.ToString() + "</td></tr>";

            _html += "<tr><td colspan='4' align='left'>If NCD is NIL, Please Provide Details : " + _ncdreson.ToString() + " </td></tr>"
            + "<tr><td colspan='4' align='left'>Has the vehicle been modified/converted in anyway from the manufacturer's specifications? " + _vhlemodifystatus.ToString() + "</td></tr>";
            if (_vhlemodifystatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width:25%' align='left'>Reason</td>"
                     + "<td colspan'3' align='left'>" + _vhlemodifyreason.ToString() + "</td></tr>";
            }

            //_html += "<tr><td colspan='4' align='left'>Are there any additional accessories installed on the vehicle? " + _accessorystatus.ToString() + "</td></tr>";
            if (_vhlemodifystatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width:25%' align='left'>Accessories Details</td>"
                     + "<td colspan'3' align='left'>" + _accessorydetail.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='4' align='left'> </td></tr>"
            + "<tr><td colspan='4' align='left'><b>Policy Details</b></td></tr>"

            + "<tr><td style='width:25%' align='left'>Finance Company</td>"
            + "<td style='width: 25%' align='left'>" + _issuebank.ToString() + "</td>"
            + "<td style='width: 25%' align='left'></td>"
            + "<td style='width: 25%' align='left'></td></tr>"

            + "<tr><td style='width:25%' align='left'>Usage</td>"
            + "<td style='width: 25%' align='left'></td>"
            + "<td style='width: 25%' align='left'>Type of Cover</td>"
            + "<td style='width: 25%' align='left'>" + _planname + "</td></tr>"

            + "<tr><td style='width:25%' align='left'>Period From </td>"
            + "<td style='width: 25%' align='left'>" + _insstartdate.ToString() + "</td>"
            + "<td style='width: 25%' align='left'>Period To</td>"
            + "<td style='width: 25%' align='left'>" + _insenddate + "</td></tr>"

            + "<tr><td colspan='4' align='left'> </td></tr>"
            + "<tr><td colspan='4' align='left'><b>Other Information</b></td></tr>"

            + "<tr><td colspan='3' align='left'>How often do you drive to West Malaysia?</td>"
            + "<td align='left'>" + _drwestmylsa.ToString() + "</td></tr>"

            + "<tr><td colspan='4' align='left'>Have you or any driver named under Section V </td></tr>"

            + "<tr><td colspan='3' align='left'>1) Been convicted of any motoring offence (other than parking) in the past three (3) years or have prosecutions pending? </td>"
            + "<td> " + _convictedstatus.ToString() + " </td></tr>";

            if (_convictedstatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width:25%' align='left'>Reason</td>"
                     + "<td colspan'3' align='left'>" + _convictedreason.ToString() + "</td></tr>";
            }

            //_html += "<tr><td colspan='4' align='left'><b>Other Information</td></tr>"

            _html += "<tr><td colspan='3' align='left'>20 Been given demerit points? If Yes, please state name of driver,total no of demerit points accumulated during the last 24 mths,the date and type of offence.</td>"
            + "<td style='width: 25%' align='left'>" + _demeritstatus.ToString() + "</td></tr>";
            if (Convert.ToInt16(_demeritcount) > 0)
            {
                _html += "<tr><td style='width:25%' align='left'>1. Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrname1.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrpoint1.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrtype1.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate1.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_demeritcount) > 1)
            {
                _html += "<tr><td style='width:25%' align='left'>2. Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrname2.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrpoint2.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrtype2.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate2.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_demeritcount) > 2)
            {
                _html += "<tr><td style='width:25%' align='left'>3. Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrname3.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrpoint3.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrtype3.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate3.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_demeritcount) > 3)
            {
                _html += "<tr><td style='width:25%' align='left'>4. Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrname4.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrpoint4.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrtype4.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate4.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_demeritcount) > 4)
            {
                _html += "<tr><td style='width:25%' align='left'>5. Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrname5.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrpoint5.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrtype5.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate5.ToString() + "</td></tr>";
            }
            if (Convert.ToInt16(_demeritcount) > 5)
            {
                _html += "<tr><td style='width:25%' align='left'>5. Driver Name</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrname6.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Total Demerit Points</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrpoint6.ToString() + "</td></tr>"

                + "<tr><td style='width:25%' align='left'>Type of Offence</td>"
                + "<td style='width: 25%' align='left'>" + _dmdrtype6.ToString() + "</td>"
                + "<td style='width: 25%' align='left'>Date</td>"
                + "<td style='width: 25%; mso-number-format:dd\\-mmm\\-yyyy' align='left'>" + _dmdrdate6.ToString() + "</td></tr>";
            }
            _html += "<tr><td colspan='3' align='left'>3) Suffer from defective vision or hearing, heart condition, epilepsy, diabetes or any physical or mental disability or infirmity?</td>"
            + "<td style='width: 25%' align='left'>" + _impairstatus.ToString() + "</td></tr>";
            if (_impairstatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _impairreason.ToString() + "</td></tr>";
            }

            _html += "<tr><td colspan='3' align='left'>4) Been refused motor insurance at any time or subjected to special conditions?</td>"
                  + "<td style='width: 25%' align='left'>" + _insrefusedstatus.ToString() + "</td></tr>";
            if (_insrefusedstatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _refusedreason.ToString() + "</td></tr>";
            }


            _html += "<tr><td colspan='3' align='left'>5) Do you have any insurance terminated in the last 12 months due to a breach of any premium payment condition?</td>"
                    + "<td style='width: 25%' align='left'>" + _inscancelstatus.ToString() + "</td></tr>";
            if (_inscancelstatus.ToString() == "Yes")
            {
                _html += "<tr><td style='width: 25%' align='left'>Reason</td>"
                + "<td colspan='3' align='left'>" + _cancelreason.ToString() + "</td></tr>";
            }


            _html += "<tr><td colspan='4' align='left'></td></tr>"
                //+ "<tr><td colspan='4' align='left'><b>Payment Before Cover Warranty (Private Vehicles)</td></tr>"
                //+"<tr><td colspan='4' align='left'>Please note that the total premium must be paid and actually received in full by the Company (or the intermediary through whom this policy was affected) on or"
                //+ " before the inception date of coverage, failing which the policy shall be deemed to be automatically cancelled and no benefits whatsoever shall be payable by the"
                //+ " Company</td></tr>"

            + "<tr><td colspan='4' align='left'><b>Premium Details</b></td></tr>"
            + "<tr><td colspan='4' align='left'>Quotation Period</td></tr>"

            + "<tr><td style='width:25%' align='left'>From Date</td>"
            + "<td style='width: 25%' align='left'>" + _insstartdate.ToString() + "</td>"
            + "<td style='width: 25%' align='left'>To Date</td>"
            + "<td style='width: 25%' align='left'>" + _insenddate.ToString() + "</td></tr>"

            + "<tr><td style='width:25%' align='left'>Annual Premium</td>"
            + "<td style='width: 25%' align='left'>$" + _annualpremium.ToString() + "</td>"
            + "<td style='width: 25%' align='left'></td>"
            + "<td style='width: 25%' align='left'></td></tr>"

            + "<tr><td colspan='4' align='left'></td></tr>"
            + "<tr><td colspan='4' align='left'><b>Mode of Payment</b></td></tr>"

            + "<tr><td style='width:25%' align='left'>Mode</td>"
            + "<td style='width: 25%' align='left'>Credit Card</td>"
            + "<td style='width: 25%' align='left'></td>"
            + "<td style='width: 25%' align='left'></td></tr>"

            + "<tr><td style='width:25%' align='left'>Card Type</td>"
            + "<td style='width: 25%' align='left'>" + _cctype.ToString() + "</td>"
            + "<td style='width: 25%' align='left'></td>"
            + "<td style='width: 25%' align='left'></td></tr>"

            + "<tr><td style='width:25%' align='left'>Card Number</td>"
            + "<td style='width: 25%' align='left'>" + _ccno.ToString() + "</td>"
            + "<td style='width: 25%' align='left'></td>"
            + "<td style='width: 25%' align='left'></td></tr>"

            + "<tr><td style='width:25%' align='left'>Card expiry date</td>"
            + "<td style='width: 25%; mso-number-format:mmm\\-yyyy' align='left'>" + _ccexmm.ToString() + "/" + _ccexyy.ToString() + "</td>"
            + "<td style='width: 25%' align='left'></td>"
            + "<td style='width: 25%' align='left'></td></tr>"


            + "<tr><td style='width:25%' align='left'>Card Holder's Name</td>"
            + "<td style='width: 25%' align='left'>" + _nameofcard.ToString() + "</td>"
            + "<td style='width: 25%' align='left'></td>"
            + "<td style='width: 25%' align='left'></td></tr>"




            + "</table>"
            + "</td>"
            + "</tr>"

            + "</table>"
            + "</div></div>";


            lblContent.Text = _html;
            MyIO myio = new MyIO();

            string[] filecontent = new string[1];
            filecontent[0] = strText + lblContent.Text.ToString();
            myio.WriteNewFile(AppDomain.CurrentDomain.BaseDirectory + "car-insurance\\proposalforms\\", _fileName + ".xls", filecontent);

            //SEND MAIL
            string _providerEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_TO");
            string _providerCCEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_CC");
            string _providerBCCEmail = CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_BCC");


            //string _providerEmail = "cherylmae.lanot@teledirect.com.sg";
            string[] filelist = new string[1];
            string _excelfile = Server.MapPath("proposalforms/" + _fileName + ".xls");
            filelist[0] = _excelfile;
            string _refid = "H" + convertno;
            MyMailManager.SendCarProposalAttachment("Liberty Insurance", _providerEmail, _providerCCEmail, _providerBCCEmail, "", CE.Global.General.GetUTCDateTime().ToShortDateString(), CE.Global.General.GetUTCDateTime().ToShortTimeString(), _refid, "HSBC", filelist);
        }

    }

    private string NoNCD(string NCD)
    {
        string _ncd = "";
        if (NCD == "0")
        {
            _ncd = "10%";
        }
        else if (NCD == "10")
        {
            _ncd = "20%";
        }
        else if (NCD == "20")
        {
            _ncd = "30%";
        }
        else if (NCD == "30")
        {
            _ncd = "40%";
        }
        else if (NCD == "40" || NCD == "50")
        {
            _ncd = "50%";
        }
        return _ncd;
    }

    private string OneTimesNCD(string NCD)
    {
        string _ncd = "";
        if (NCD == "0" || NCD == "10" || NCD == "20" || NCD == "30")
        {
            _ncd = "0%";
        }
        else if (NCD == "40")
        {
            _ncd = "10%";
        }
        else if (NCD == "50")
        {
            _ncd = "20%";
        }
        return _ncd;
    }

    private string IsYesNo(string option)
    {
        string IsYes = "Yes";

        if (option == "False")
            IsYes = "No";

        return IsYes;
    }

    private string[] GeneratePDFProposalForm(Int64 RefID, Int32 UserType)
    {
        string[] filelist = new string[1];

        LibertyCarInsurancePDFOutput GeneratePDF = new LibertyCarInsurancePDFOutput();

        string convertno = General.GetRefNumber(RefID);
        string _fileName = "L" + convertno + "_" + CE.Global.General.GetUTCDateTime().Day.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Month.ToString("00") + "-" + CE.Global.General.GetUTCDateTime().Year;

        DataSet _dsProposal = new DataSet();
        ProposalDownloadDB _proposaldownloaddb = new ProposalDownloadDB();
        _dsProposal = _proposaldownloaddb.GetLibertyProposal(RefID, "CI");


        if (_dsProposal.Tables[0].Rows.Count > 0)
        {
            GeneratePDF.ClearFields();
            #region variables
            string _name, _unitno, _homeno, _address, _postalcode, _dob, _dd, _mm, _yy, _nationality, _nric, _maritalstatus, _officeno, _mobile;
            string _gender, _expdriving, _vehicleno, _make, _model, _vehicletype, _engineno, _chassisno, _cc, _regyear, _mfgyear, _hpstatus, _hpcomp;
            string _insstartdate, _insenddate, _isdd, _ismm, _isyy, _iedd, _iemm, _ieyy, _insstatus, _inscomp, _insvhleno, _insncdentitle;
            string _inspldate, _indd, _inmm, _inyy, _ncdreson, _bodytype, _occupation, _empname, _drwestmylsa, _vhlemodifystatus, _vhlemodifyreason;
            string _drname1, _drage1, _drgender1, _drmarital1, _drocc1, _drexp1, _drname2, _drage2, _drgender2, _drmarital2, _drocc2, _drexp2;
            string _drname3, _drage3, _drgender3, _drmarital3, _drocc3, _drexp3, _drname4, _drage4, _drgender4, _drmarital4, _drocc4, _drexp4;
            string _drname5, _drage5, _drgender5, _drmarital5, _drocc5, _drexp5, _demeritstatus, _demeritcount, _dmdrname1, _dmdrpoint1, _producerCode;
            string _drDOB1, _drDOB2, _drDOB3, _drDOB4, _drDOB5;
            string _dmdrdate1, _dmdrtype1, _dmdrname2, _dmdrpoint2, _dmdrdate2, _dmdrtype2, _dmdrname3, _dmdrpoint3, _dmdrdate3, _dmdrtype3;
            string _dmdrname4, _dmdrpoint4, _dmdrdate4, _dmdrtype4, _dmdrname5, _dmdrpoint5, _dmdrdate5, _dmdrtype5, _dmdrname6, _dmdrpoint6;
            string _dmdrdate6, _dmdrtype6, _adddriver, _drcount, _paymenttype, _installmenttype, _nameofcard, _issuebank, _ccno, _cno, _ccexmm, _ccexyy, _cctype, _claimstatus, _claim1ststat, _claim1stend;
            string _claimcount1, claimamt1, _claim2ndstat, _claim2ndend, claimamt2, _claim3rdstat, _claim3rdend, claimamt3, _ncdstatus, _ncdpercent, _ncdnil;
            string _inscancelstatus, _cancelreason, _impairstatus, _impairreason, _accessorystatus, _accessorydetail, _convictedstatus, _convictedreason, _planname, _basicpremium, _annualpremium, _agerestriction, _agerestrictionamount;
            string _insrefusedstatus, _refusedreason, _jobnature, _email, _ncdexisting, _claimcount, _claimcount2, _claimcount3;
            string _drjobnature1, _drjobnature2, _drjobnature3, _drjobnature4, _drjobnature5;
            string _isoffpeak;
            int _excess, _cxcovertypeid;
            bool _isncdprotect = false;
            bool _isOFD = false;
            DateTime _dofb, _isdate, _iedate, _indate;
            Int32 _intclm1, _intclm2, _intclm3;

            _email = ""; _mfgyear = "1990"; _regyear = "1990"; _cc = "1111"; _ncdexisting = "0"; _claimcount = "0";
            _jobnature = ""; _drjobnature1 = ""; _drjobnature2 = ""; _drjobnature3 = ""; _drjobnature4 = ""; _drjobnature5 = "";
            _inscancelstatus = "false"; _cancelreason = ""; _impairstatus = "false"; _impairreason = ""; _demeritstatus = "false"; _demeritcount = "";
            _dmdrname1 = ""; _dmdrpoint1 = ""; _dmdrdate1 = ""; _dmdrtype1 = ""; _dmdrname2 = ""; _dmdrpoint2 = ""; _dmdrdate2 = ""; _dmdrtype2 = "";
            _dmdrname3 = ""; _dmdrpoint3 = ""; _dmdrdate3 = ""; _dmdrtype3 = ""; _dmdrname4 = ""; _dmdrdate4 = ""; _dmdrtype4 = "";
            _dmdrpoint4 = ""; _dmdrname5 = ""; _dmdrpoint5 = ""; _dmdrdate5 = ""; _dmdrtype5 = ""; _dmdrname6 = ""; _producerCode = "D9999-CX";
            _dmdrpoint6 = ""; _dmdrdate6 = ""; _dmdrtype6 = ""; _vehicletype = ""; _expdriving = "0";
            _drname1 = ""; _drage1 = ""; _drgender1 = ""; _drmarital1 = ""; _drocc1 = ""; _drexp1 = "0";
            _drname2 = ""; _drage2 = ""; _drgender2 = ""; _drmarital2 = ""; _drocc2 = ""; _drexp2 = "0";
            _drname3 = ""; _drage3 = ""; _drgender3 = ""; _drmarital3 = ""; _drocc3 = ""; _drexp3 = "0";
            _drname4 = ""; _drage4 = ""; _drgender4 = ""; _drmarital4 = ""; _drocc4 = ""; _drexp4 = "0";
            _drname5 = ""; _drage5 = ""; _drgender5 = ""; _drmarital5 = ""; _drocc5 = ""; _drexp5 = "0"; _planname = ""; _annualpremium = "0"; _agerestriction = "0"; _agerestrictionamount = "0";
            _adddriver = ""; _drcount = ""; _paymenttype = ""; _installmenttype = ""; _nameofcard = ""; _issuebank = ""; _ccno = ""; _ccexmm = ""; _ccexyy = ""; _cctype = "";
            _insrefusedstatus = "false"; _refusedreason = ""; _excess = 0;
            _drDOB1 = "01/01/1980"; _drDOB2 = "01/01/1980"; _drDOB3 = "01/01/1980"; _drDOB4 = "01/01/1980"; _drDOB5 = "01/01/1980";
            _inspldate = "01/01/1980"; _cxcovertypeid = 0;
            _isoffpeak = "";
            _claimcount2 = "0"; _claimcount3 = "0"; _intclm1 = 0; _intclm2 = 0; _intclm3 = 0;

            _name = _dsProposal.Tables[0].Rows[0]["Name"].ToString();
            _dofb = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["DOB"].ToString());
            _dd = _dofb.Day.ToString("00");
            _mm = _dofb.Month.ToString("00");
            _yy = _dofb.Year.ToString();
            //_dob = _dd + "/" + _mm + "/" + _yy;
            _dob = _dsProposal.Tables[0].Rows[0]["DOB"].ToString();
            _nationality = _dsProposal.Tables[0].Rows[0]["Nationality"].ToString();
            _unitno = _dsProposal.Tables[0].Rows[0]["UnitNo"].ToString();
            _homeno = _dsProposal.Tables[0].Rows[0]["HomeNo"].ToString();
            _address = _dsProposal.Tables[0].Rows[0]["Address"].ToString();
            _postalcode = _dsProposal.Tables[0].Rows[0]["PostalCode"].ToString();
            _nric = _dsProposal.Tables[0].Rows[0]["NRICNo"].ToString();
            _maritalstatus = _dsProposal.Tables[0].Rows[0]["Marital"].ToString();
            _gender = _dsProposal.Tables[0].Rows[0]["Gender"].ToString();
            _jobnature = _dsProposal.Tables[0].Rows[0]["NofBusi"].ToString();
            _email = _dsProposal.Tables[0].Rows[0]["Email"].ToString();
            _cxcovertypeid = Convert.ToInt32(_dsProposal.Tables[0].Rows[0]["CXCoverTypeId"].ToString());

            _planname = _dsProposal.Tables[0].Rows[0]["PlanName"].ToString();
            _annualpremium = _dsProposal.Tables[0].Rows[0]["AnnualPremium"].ToString();
            _excess = int.Parse(_dsProposal.Tables[0].Rows[0]["Excess"].ToString());
            //Phyo
            _basicpremium = _dsProposal.Tables[0].Rows[0]["FInfo2"].ToString();
            //Sakthi on 10 Jan 2011 - start
            if (_dsProposal.Tables[0].Rows[0]["NInfo5"].ToString() != null)
            {
                _agerestriction = _dsProposal.Tables[0].Rows[0]["NInfo5"].ToString();
            }

            //if (_agerestriction != "0")
            //{
            //    _basicpremium = _dsProposal.Tables[0].Rows[0]["FInfo2"].ToString();
            //}
            //Sakthi on 10 Jan 2011 - end

            _drwestmylsa = _dsProposal.Tables[0].Rows[0]["DrWMalaysia"].ToString();
            _expdriving = _dsProposal.Tables[0].Rows[0]["YearDriveSg"].ToString();
            _occupation = _dsProposal.Tables[0].Rows[0]["Description"].ToString();
            _mobile = _dsProposal.Tables[0].Rows[0]["MobileNo"].ToString();
            _officeno = _dsProposal.Tables[0].Rows[0]["OfficePhoneNo"].ToString();
            _empname = _dsProposal.Tables[0].Rows[0]["EmpNameandTrade"].ToString();
            _isOFD = Convert.ToBoolean(_dsProposal.Tables[0].Rows[0]["IsOffDriveCom"]);
            //Cheryl on 28 June 2011
            _isoffpeak = _dsProposal.Tables[0].Rows[0]["Offbeak"].ToString();

            if (_dsProposal.Tables[0].Rows[0]["Ninfo1"] != null && _dsProposal.Tables[0].Rows[0]["Ninfo1"].ToString() != "")
            {
                Int64 _Agent = Convert.ToInt64(_dsProposal.Tables[0].Rows[0]["Ninfo1"].ToString());
                if (_Agent == 0)
                {
                    _producerCode = "D9999-CX";
                }
                else
                {
                    _producerCode = "D9999-TD";
                }
            }
            else
            {
                _producerCode = "D9999-CX";
            }

            if (_dsProposal.Tables[0].Rows[0]["Info3"] != null && _dsProposal.Tables[0].Rows[0]["Info3"].ToString() != "")
                if (_dsProposal.Tables[0].Rows[0]["Info3"].ToString() == "1")
                    _isncdprotect = true;
                else
                    _isncdprotect = false;

            if (_dsProposal.Tables[0].Rows[0]["IsClaimLastThreeYear"].ToString() == "False")
            {
                _claimstatus = "No";
            }
            else
            {
                _claimstatus = "Yes";
                _claimcount = _dsProposal.Tables[1].Rows[0]["NOCLast1"].ToString();
            }
            if (_dsProposal.Tables[0].Rows[0]["HasPreInsurer"].ToString() == "True")
            {
                _insstatus = "Yes";
                if (_dsProposal.Tables[2].Rows.Count > 0)
                {
                    _inscomp = _dsProposal.Tables[2].Rows[0]["InsCompanyName"].ToString();
                    _insvhleno = _dsProposal.Tables[0].Rows[0]["PreInsVechicleNo"].ToString();
                    _indate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["PreInsExpiryDate"].ToString());
                    _indd = _indate.Day.ToString("00");
                    _inmm = _indate.Month.ToString("00");
                    _inyy = _indate.Year.ToString();
                    //_inspldate = _dd + "/" + _mm + "/" + _yy;
                    _inspldate = _dsProposal.Tables[0].Rows[0]["PreInsExpiryDate"].ToString();
                    if (_dsProposal.Tables[0].Rows[0]["NCDEntitlement"].ToString() == "-1")
                    {
                        _insncdentitle = "false";
                    }
                    else
                    {
                        _insncdentitle = _dsProposal.Tables[0].Rows[0]["NCDEntitlement"].ToString() + "%";
                    }
                }
                else
                {
                    _insstatus = "false";
                    _inscomp = "";
                    _insvhleno = "";
                    _inspldate = "01/01/1990";
                    _insncdentitle = "false";
                }
            }
            else
            {
                _insstatus = "false";
                _inscomp = "";
                _insvhleno = "";
                _inspldate = "1/1/1990";
                _insncdentitle = "false";
            }

            _ncdexisting = _dsProposal.Tables[0].Rows[0]["NCDPercent"].ToString();
            _ncdpercent = _dsProposal.Tables[0].Rows[0]["NextNCD"].ToString();

            _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDReason"].ToString();
            if (_ncdreson == "Others")
            {
                _ncdreson = _dsProposal.Tables[0].Rows[0]["NCDOtherReason"].ToString();
            }
            else if (_ncdreson == "-1")
            {
                _ncdreson = "";
            }

            _paymenttype = _dsProposal.Tables[0].Rows[0]["PamentType"].ToString();

            if (_dsProposal.Tables[1].Rows.Count > 0)
            {
                _claim1ststat = _dsProposal.Tables[1].Rows[0]["Claim1stStartDate"].ToString();
                _claim1stend = _dsProposal.Tables[1].Rows[0]["Claim1stEndDate"].ToString();
                claimamt1 = _dsProposal.Tables[1].Rows[0]["NOCLast1Value"].ToString();
                _claimcount1 = _dsProposal.Tables[1].Rows[0]["NOCLast1"].ToString();

                _claim2ndstat = _dsProposal.Tables[1].Rows[0]["Claim2ndStartDate"].ToString();
                _claim2ndend = _dsProposal.Tables[1].Rows[0]["Claim2ndEndDate"].ToString();
                claimamt2 = _dsProposal.Tables[1].Rows[0]["NOCLast2Value"].ToString();
                _claimcount2 = _dsProposal.Tables[1].Rows[0]["NOCLast2"].ToString();

                _claim3rdstat = _dsProposal.Tables[1].Rows[0]["Claim3rdStartDate"].ToString();
                _claim3rdend = _dsProposal.Tables[1].Rows[0]["Claim3rdEndDate"].ToString();
                claimamt3 = _dsProposal.Tables[1].Rows[0]["NOCLast3Value"].ToString();
                _claimcount3 = _dsProposal.Tables[1].Rows[0]["NOCLast3"].ToString();
            }
            else
            {
                _claim1ststat = "";
                _claim1stend = "";
                claimamt1 = "";
                _claimcount1 = "0";

                _claim2ndstat = "";
                _claim2ndend = "";
                claimamt2 = "";
                _claimcount2 = "0";

                _claim3rdstat = "";
                _claim3rdend = "";
                claimamt3 = "";
                _claimcount3 = "0";
                _claimstatus = "No";

            }

            if (_claimstatus.ToUpper() == "YES")
            {
                if (!Int32.TryParse(_claimcount1, out _intclm1))
                {
                    _intclm1 = 0;
                }
                if (!Int32.TryParse(_claimcount2, out _intclm2))
                {
                    _intclm2 = 0;
                }
                if (!Int32.TryParse(_claimcount3, out _intclm3))
                {
                    _intclm3 = 0;
                }
                _claimcount = (_intclm1 + _intclm2 + _intclm3).ToString();
            }

            _vhlemodifystatus = _dsProposal.Tables[0].Rows[0]["HasVechicleModified"].ToString();
            if (_dsProposal.Tables[0].Rows[0]["HasVechicleModified"].ToString() == "True")
            {
                _vhlemodifyreason = _dsProposal.Tables[0].Rows[0]["VechicleModifyReason"].ToString();
            }
            else
            {
                _vhlemodifyreason = "";
            }
            _inscancelstatus = _dsProposal.Tables[0].Rows[0]["HasInsuranceTerminated"].ToString();
            if (_dsProposal.Tables[0].Rows[0]["HasInsuranceTerminated"].ToString() == "True")
            {
                _cancelreason = _dsProposal.Tables[0].Rows[0]["InsuranceTerminatedReason"].ToString();
            }
            else
            {
                _cancelreason = "";
            }
            _impairstatus = _dsProposal.Tables[0].Rows[0]["HasPhysicalImpairment"].ToString();
            if (_dsProposal.Tables[0].Rows[0]["HasPhysicalImpairment"].ToString() == "True")
            {
                _impairreason = _dsProposal.Tables[0].Rows[0]["PhysicalImpairmentReason"].ToString();
            }
            else
            {
                _impairreason = "";
            }

            _convictedstatus = _dsProposal.Tables[0].Rows[0]["HasConvictedMoterOffence"].ToString();
            if (_dsProposal.Tables[0].Rows[0]["HasConvictedMoterOffence"].ToString() == "True")
            {
                _convictedreason = _dsProposal.Tables[0].Rows[0]["ConvictedReason"].ToString();
            }
            else
            {
                _convictedreason = "";
            }

            _accessorystatus = _dsProposal.Tables[0].Rows[0]["HasAccessory"].ToString();
            if (_dsProposal.Tables[0].Rows[0]["HasAccessory"].ToString() == "True")
            {
                _accessorydetail = _dsProposal.Tables[0].Rows[0]["AccessoryDescription"].ToString();
            }
            else
            {
                _accessorydetail = "";
            }

            if (_dsProposal.Tables[0].Rows[0]["Info1"].ToString() == "1")
            {
                _insrefusedstatus = "true";
                _refusedreason = _dsProposal.Tables[0].Rows[0]["Info2"].ToString();
            }
            else
            {
                _insrefusedstatus = "false";
                _refusedreason = "";
            }

            _demeritstatus = _dsProposal.Tables[0].Rows[0]["HasDemeritPoints"].ToString();
            if (_dsProposal.Tables[0].Rows[0]["HasDemeritPoints"].ToString() == "True")
            {
                if (_dsProposal.Tables[6].Rows.Count > 0)
                {
                    _demeritcount = _dsProposal.Tables[6].Rows.Count.ToString();

                    _dmdrname1 = _dsProposal.Tables[6].Rows[0]["DriverName"].ToString();
                    _dmdrpoint1 = _dsProposal.Tables[6].Rows[0]["TotalDemeritPoints"].ToString();
                    _dmdrdate1 = _dsProposal.Tables[6].Rows[0]["DemeritDate"].ToString();
                    _dmdrtype1 = _dsProposal.Tables[6].Rows[0]["TypeofOffence"].ToString();
                    if (_dsProposal.Tables[6].Rows.Count > 1)
                    {
                        _dmdrname2 = _dsProposal.Tables[6].Rows[1]["DriverName"].ToString();
                        _dmdrpoint2 = _dsProposal.Tables[6].Rows[1]["TotalDemeritPoints"].ToString();
                        _dmdrdate2 = _dsProposal.Tables[6].Rows[1]["DemeritDate"].ToString();
                        _dmdrtype2 = _dsProposal.Tables[6].Rows[1]["TypeofOffence"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 2)
                    {
                        _dmdrname3 = _dsProposal.Tables[6].Rows[2]["DriverName"].ToString();
                        _dmdrpoint3 = _dsProposal.Tables[6].Rows[2]["TotalDemeritPoints"].ToString();
                        _dmdrdate3 = _dsProposal.Tables[6].Rows[2]["DemeritDate"].ToString();
                        _dmdrtype3 = _dsProposal.Tables[6].Rows[2]["TypeofOffence"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 3)
                    {
                        _dmdrname4 = _dsProposal.Tables[6].Rows[3]["DriverName"].ToString();
                        _dmdrpoint4 = _dsProposal.Tables[6].Rows[3]["TotalDemeritPoints"].ToString();
                        _dmdrdate4 = _dsProposal.Tables[6].Rows[3]["DemeritDate"].ToString();
                        _dmdrtype4 = _dsProposal.Tables[6].Rows[3]["TypeofOffence"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 4)
                    {
                        _dmdrname5 = _dsProposal.Tables[6].Rows[4]["DriverName"].ToString();
                        _dmdrpoint5 = _dsProposal.Tables[6].Rows[4]["TotalDemeritPoints"].ToString();
                        _dmdrdate5 = _dsProposal.Tables[6].Rows[4]["DemeritDate"].ToString();
                        _dmdrtype5 = _dsProposal.Tables[6].Rows[4]["TypeofOffence"].ToString();
                    }
                    if (_dsProposal.Tables[6].Rows.Count > 5)
                    {
                        _dmdrname6 = _dsProposal.Tables[6].Rows[5]["DriverName"].ToString();
                        _dmdrpoint6 = _dsProposal.Tables[6].Rows[5]["TotalDemeritPoints"].ToString();
                        _dmdrdate6 = _dsProposal.Tables[6].Rows[5]["DemeritDate"].ToString();
                        _dmdrtype6 = _dsProposal.Tables[6].Rows[5]["TypeofOffence"].ToString();
                    }
                }
                else
                {
                    _demeritstatus = "false";
                    _demeritcount = "0";
                }
            }
            else
            {
                _demeritstatus = "false";
                _demeritcount = "0";
            }

            _vehicleno = _dsProposal.Tables[0].Rows[0]["VechicleNo"].ToString();
            _mfgyear = _dsProposal.Tables[0].Rows[0]["ManufactYear"].ToString();
            _regyear = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["DateofReg"]).Year.ToString();
            _model = _dsProposal.Tables[5].Rows[0]["Description"].ToString();
            _make = _dsProposal.Tables[5].Rows[0]["Make"].ToString();
            _cc = _dsProposal.Tables[5].Rows[0]["CC"].ToString();
            _vehicletype = _dsProposal.Tables[5].Rows[0]["Body"].ToString();
            _engineno = _dsProposal.Tables[0].Rows[0]["EngineNo"].ToString();
            _chassisno = _dsProposal.Tables[0].Rows[0]["ChassisNo"].ToString();

            _isdate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["StartDate"].ToString());
            _isdd = _isdate.Day.ToString("00");
            _ismm = _isdate.Month.ToString("00");
            _isyy = _isdate.Year.ToString();
            //_insstartdate = _isdd + "/" + _ismm + "/" + _isyy;
            _insstartdate = _dsProposal.Tables[0].Rows[0]["StartDate"].ToString();

            _iedate = Convert.ToDateTime(_dsProposal.Tables[0].Rows[0]["EndDate"].ToString());
            _iedd = _iedate.Day.ToString("00");
            _iemm = _iedate.Month.ToString("00");
            _ieyy = _iedate.Year.ToString();
            //_insenddate = _iedd + "/" + _iemm + "/" + _ieyy;
            _insenddate = _dsProposal.Tables[0].Rows[0]["EndDate"].ToString();

            if (_dsProposal.Tables[3].Rows.Count > 0)
            {
                _hpstatus = "false";
                _hpcomp = _dsProposal.Tables[3].Rows[0]["HPCompanyName"].ToString();

                if (_hpcomp.ToString() == "")
                {
                    _hpcomp = "Not Applicable";
                }
            }
            else
            {
                _hpstatus = "false";
                _hpcomp = "Not Applicable";
            }
            if (_dsProposal.Tables[0].Rows[0]["AddDriver"].ToString() == "Yes")
            {
                _adddriver = "true";
                _drcount = _dsProposal.Tables[0].Rows[0]["NoOfDriver"].ToString();
            }
            else
            {
                _adddriver = "false";
                _drcount = "0";
            }
            if (_dsProposal.Tables[4].Rows.Count > 0)
            {
                if (Convert.ToInt16(_drcount) > 0)
                {
                    _drname1 = _dsProposal.Tables[4].Rows[0]["DriverName"].ToString();
                    _drage1 = _dsProposal.Tables[4].Rows[0]["Age"].ToString();
                    _drgender1 = _dsProposal.Tables[4].Rows[0]["Gender"].ToString();
                    _drmarital1 = _dsProposal.Tables[4].Rows[0]["Marital"].ToString();
                    _drocc1 = _dsProposal.Tables[4].Rows[0]["Description"].ToString();
                    _drexp1 = _dsProposal.Tables[4].Rows[0]["YearOfDrivingInSg"].ToString();
                    _drDOB1 = _dsProposal.Tables[4].Rows[0]["DOB"].ToString();
                    _drjobnature1 = _dsProposal.Tables[4].Rows[0]["JobNature"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 1)
                {
                    _drname2 = _dsProposal.Tables[4].Rows[1]["DriverName"].ToString();
                    _drage2 = _dsProposal.Tables[4].Rows[1]["Age"].ToString();
                    _drgender2 = _dsProposal.Tables[4].Rows[1]["Gender"].ToString();
                    _drmarital2 = _dsProposal.Tables[4].Rows[1]["Marital"].ToString();
                    _drocc2 = _dsProposal.Tables[4].Rows[1]["Description"].ToString();
                    _drexp2 = _dsProposal.Tables[4].Rows[1]["YearOfDrivingInSg"].ToString();
                    _drDOB2 = _dsProposal.Tables[4].Rows[1]["DOB"].ToString();
                    _drjobnature2 = _dsProposal.Tables[4].Rows[1]["JobNature"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 2)
                {
                    _drname3 = _dsProposal.Tables[4].Rows[2]["DriverName"].ToString();
                    _drage3 = _dsProposal.Tables[4].Rows[2]["Age"].ToString();
                    _drgender3 = _dsProposal.Tables[4].Rows[2]["Gender"].ToString();
                    _drmarital3 = _dsProposal.Tables[4].Rows[2]["Marital"].ToString();
                    _drocc3 = _dsProposal.Tables[4].Rows[2]["Description"].ToString();
                    _drexp3 = _dsProposal.Tables[4].Rows[2]["YearOfDrivingInSg"].ToString();
                    _drDOB3 = _dsProposal.Tables[4].Rows[2]["DOB"].ToString();
                    _drjobnature3 = _dsProposal.Tables[4].Rows[2]["JobNature"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 3)
                {
                    _drname4 = _dsProposal.Tables[4].Rows[3]["DriverName"].ToString();
                    _drage4 = _dsProposal.Tables[4].Rows[3]["Age"].ToString();
                    _drgender4 = _dsProposal.Tables[4].Rows[3]["Gender"].ToString();
                    _drmarital4 = _dsProposal.Tables[4].Rows[3]["Marital"].ToString();
                    _drocc4 = _dsProposal.Tables[4].Rows[3]["Description"].ToString();
                    _drexp4 = _dsProposal.Tables[4].Rows[3]["YearOfDrivingInSg"].ToString();
                    _drDOB4 = _dsProposal.Tables[4].Rows[3]["DOB"].ToString();
                }
                if (Convert.ToInt16(_drcount) > 4)
                {
                    _drname5 = _dsProposal.Tables[4].Rows[4]["DriverName"].ToString();
                    _drage5 = _dsProposal.Tables[4].Rows[4]["Age"].ToString();
                    _drgender5 = _dsProposal.Tables[4].Rows[4]["Gender"].ToString();
                    _drmarital5 = _dsProposal.Tables[4].Rows[4]["Marital"].ToString();
                    _drocc5 = _dsProposal.Tables[4].Rows[4]["Description"].ToString();
                    _drexp5 = _dsProposal.Tables[4].Rows[4]["YearOfDrivingInSg"].ToString();
                    _drDOB5 = _dsProposal.Tables[4].Rows[4]["DOB"].ToString();
                    _drjobnature5 = _dsProposal.Tables[4].Rows[4]["JobNature"].ToString();
                }
            }


            DataSet _dsPayment = new DataSet();
            if (rdoCreditCard.Checked)
            {
                _dsPayment = _proposaldownloaddb.GetPaymentDetails(RefID, 29, "CI");
                if (_dsPayment != null && _dsPayment.Tables[0].Rows.Count > 0)
                {
                    _nameofcard = _dsPayment.Tables[0].Rows[0]["NameoftheCard"].ToString();
                    _issuebank = _dsPayment.Tables[0].Rows[0]["IssuingBankName"].ToString();
                    _cno = _dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString();
                    _ccexmm = _dsPayment.Tables[0].Rows[0]["CardExpiryMonth"].ToString();
                    _ccexyy = _dsPayment.Tables[0].Rows[0]["CardExpiryYear"].ToString();
                    _cctype = _dsPayment.Tables[0].Rows[0]["CardType"].ToString();
                    _installmenttype = _dsPayment.Tables[0].Rows[0]["Installment"].ToString();
                    if (_dsPayment.Tables[0].Rows[0]["CreditCardNo"].ToString() != "")
                        _ccno = _cno.Substring(0, 4) + "-" + _cno.Substring(4, 4) + "-" + _cno.Substring(8, 4) + "-" + _cno.Substring(12, 4);
                    else
                        _ccno = "";

                }
            }
            #endregion

            GeneratePDF.CxCoverTypeId = _cxcovertypeid;
            GeneratePDF.ProposalNo = ""; // "L" + convertno;
            GeneratePDF.QuotationNo = "L" + convertno;
            GeneratePDF.ApplicationDate = CE.Global.General.GetUTCDateTime();
            GeneratePDF.NRIC = _nric;
            GeneratePDF.CustomerName = _name;
            GeneratePDF.CustomerAddress = _address;
            GeneratePDF.CustomerUnitNo = _unitno;
            GeneratePDF.CustomerHomeNo = _homeno;
            GeneratePDF.CustomerPostCode = _postalcode;
            GeneratePDF.MobileNo = _mobile;
            GeneratePDF.OfficeNo = _officeno;
            //GeneratePDF.OfficeMobileNo = _mobile + "/" + _officeno;
            GeneratePDF.EmployersName = _empname;
            GeneratePDF.EmailAddress = _email;
            GeneratePDF.CustomerDOB = Convert.ToDateTime(_dob);
            GeneratePDF.CustomerGender = _gender;
            GeneratePDF.CustomerOccupation = _occupation;
            GeneratePDF.CustomerJobNature = _jobnature;
            GeneratePDF.CustomerMaritalStatus = _maritalstatus;
            GeneratePDF.CustomerDrivingExperience = int.Parse(_expdriving);
            //cheryl 28 june 2011
            if (_isoffpeak == "Yes")
            {
                GeneratePDF.Usage = "Weekend Use";
            }
            else
            {
                GeneratePDF.Usage = "Private Use";
            }


            GeneratePDF.Driver1Name = _drname1;
            GeneratePDF.Driver1gender = _drgender1;
            GeneratePDF.Driver1DOB = Convert.ToDateTime(_drDOB1);
            GeneratePDF.Driver1Occupation = _drocc1;
            GeneratePDF.Driver1JobNature = _drjobnature1;
            GeneratePDF.Driver1MaritalStatus = _drmarital1;
            GeneratePDF.Driver1DrivingExperience = int.Parse(_drexp1);

            GeneratePDF.Driver2Name = _drname2;
            GeneratePDF.Driver2gender = _drgender2;
            GeneratePDF.Driver2DOB = Convert.ToDateTime(_drDOB2);
            GeneratePDF.Driver2Occupation = _drocc2;
            GeneratePDF.Driver2JobNature = _drjobnature2;
            GeneratePDF.Driver2MaritalStatus = _drmarital2;
            GeneratePDF.Driver2DrivingExperience = int.Parse(_drexp2);

            GeneratePDF.Driver3Name = _drname3;
            GeneratePDF.Driver3gender = _drgender3;
            GeneratePDF.Driver3DOB = Convert.ToDateTime(_drDOB3);
            GeneratePDF.Driver3Occupation = _drocc3;
            GeneratePDF.Driver3JobNature = _drjobnature3;
            GeneratePDF.Driver3MaritalStatus = _drmarital3;
            GeneratePDF.Driver3DrivingExperience = int.Parse(_drexp3);

            GeneratePDF.Driver4Name = _drname4;
            GeneratePDF.Driver4gender = _drgender4;
            GeneratePDF.Driver4DOB = Convert.ToDateTime(_drDOB4);
            GeneratePDF.Driver4Occupation = _drocc4;
            GeneratePDF.Driver4JobNature = _drjobnature4;
            GeneratePDF.Driver4MaritalStatus = _drmarital4;
            GeneratePDF.Driver4DrivingExperience = int.Parse(_drexp4);

            GeneratePDF.Driver5Name = _drname5;
            GeneratePDF.Driver5gender = _drgender5;
            GeneratePDF.Driver5DOB = Convert.ToDateTime(_drDOB5);
            GeneratePDF.Driver5Occupation = _drocc5;
            GeneratePDF.Driver5JobNature = _drjobnature5;
            GeneratePDF.Driver5MaritalStatus = _drmarital5;
            GeneratePDF.Driver5DrivingExperience = int.Parse(_drexp5);

            GeneratePDF.VehicleNo = _vehicleno;
            GeneratePDF.ChassisNo = _chassisno;
            GeneratePDF.EngineNo = _engineno;
            GeneratePDF.BodyType = _vehicletype;
            GeneratePDF.CarMake = _make;

            string modelonly = "";

            if ((_make.ToLower() == "alfa romeo") || (_make.ToLower() == "land rover"))
            {
                modelonly = _model.Substring(11);
            }
            else if (_make.ToLower() == "mercedes benz")
            {
                modelonly = _model.Substring(12);
            }
            else
            {
                int spacecheck = _model.IndexOf(" ") + 1;
                modelonly = _model.Substring(spacecheck);
            }

            GeneratePDF.CarModel = modelonly;
            GeneratePDF.YearOfManufacture = int.Parse(_mfgyear);
            GeneratePDF.YearOfRegistration = int.Parse(_regyear);
            GeneratePDF.CarSeaters = 0;
            GeneratePDF.CarCC = int.Parse(_cc);
            GeneratePDF.OdometerReading = "";
            GeneratePDF.EstimatedMarketValue = "";

            GeneratePDF.CurrentInsuranceCo = _inscomp;
            GeneratePDF.PolicyNo = "";
            GeneratePDF.ExpiryCancellationDate = Convert.ToDateTime(_inspldate);
            GeneratePDF.Last3YearsClaimXP = _claimstatus;
            GeneratePDF.NoClaimsLast3Years = _claimcount;

            //if (_ncdpercent == "-1")
            //    GeneratePDF.NCDPercent = "No NCD(first policy)";
            //else
            GeneratePDF.NCDPercent = _ncdpercent;

            GeneratePDF.NCDNilDetails = _ncdreson;

            GeneratePDF.IsCarModified = bool.Parse(_vhlemodifystatus);
            GeneratePDF.ModifiedReason = _vhlemodifyreason;

            GeneratePDF.FinanceCo = _hpcomp;
            GeneratePDF.ConvictedReason = _convictedreason;
            //GeneratePDF.PeriodFrom = Convert.ToDateTime(_insstartdate);
            //GeneratePDF.PeriodTo = Convert.ToDateTime(_insenddate);
            GeneratePDF.PeriodFrom = Convert.ToDateTime(_insstartdate);
            GeneratePDF.PeriodTo = Convert.ToDateTime(_insenddate);
            GeneratePDF.TypeOfCover = _planname;

            GeneratePDF.DriveToWestMalaysia = _drwestmylsa;
            GeneratePDF.IsConvictedOfMotoringOffense = bool.Parse(_convictedstatus);
            GeneratePDF.ConvictedReason = _convictedreason;
            GeneratePDF.IsGivenDemeritPoints = bool.Parse(_demeritstatus);

            if (_dmdrtype6 != "")
            {
                GeneratePDF.DemeritPointsReason = _dmdrtype1 + ", " + _dmdrtype2 + ", " + _dmdrtype3 + ", " + _dmdrtype4 + ", " + _dmdrtype5 + ", " + _dmdrtype6;
            }
            else if (_dmdrtype5 != "")
            {
                GeneratePDF.DemeritPointsReason = _dmdrtype1 + ", " + _dmdrtype2 + ", " + _dmdrtype3 + ", " + _dmdrtype4 + ", " + _dmdrtype5;
            }
            else if (_dmdrtype4 != "")
            {
                GeneratePDF.DemeritPointsReason = _dmdrtype1 + ", " + _dmdrtype2 + ", " + _dmdrtype3 + ", " + _dmdrtype4;
            }
            else if (_dmdrtype3 != "")
            {
                GeneratePDF.DemeritPointsReason = _dmdrtype1 + ", " + _dmdrtype2 + ", " + _dmdrtype3;
            }
            else if (_dmdrtype2 != "")
            {
                GeneratePDF.DemeritPointsReason = _dmdrtype1 + ", " + _dmdrtype2;
            }
            else if (_dmdrtype1 != "")
            {
                GeneratePDF.DemeritPointsReason = _dmdrtype1;
            }

            GeneratePDF.isDisabled = Convert.ToBoolean(_impairstatus);
            GeneratePDF.DisablityReason = _impairreason;

            GeneratePDF.IsRefusedMotorInsurance = Convert.ToBoolean(_insrefusedstatus);
            GeneratePDF.RefusedReason = _refusedreason;

            GeneratePDF.IsTerminatedDueToPayment = Convert.ToBoolean(_inscancelstatus);
            GeneratePDF.TerminatedReason = _cancelreason;

            GeneratePDF.TotalPremium = float.Parse(_annualpremium);

            if (_cxcovertypeid == 5)
            {
                GeneratePDF.TotalPremium += 321;
            }
            else if (_cxcovertypeid == 6)
            {
                GeneratePDF.TotalPremium += 160.5f;
            }
            else if (_cxcovertypeid == 7)
            {
                GeneratePDF.TotalPremium += 642;
            }

            GeneratePDF.Excess = _excess;
            GeneratePDF.ProducerCode = _producerCode;

            float grosspremium = 0;
            float gstrate = 0;
            float ofdrate = 0;
            float adddiscrate = 0;
            float ncdrate = 0;
            float basicpremium = 0;
            float ncdprotectrate = 0;
            float additionaldriverrate = 0;

            //if (_drcount != "0")
            //{
            //    additionaldriverrate = (25 * int.Parse(_drcount)) * 1.07;
            //}

            if (_isOFD)
                GeneratePDF.OFD = "Yes";
            else
                GeneratePDF.OFD = "No";

            if (_isncdprotect)
                GeneratePDF.NCDProtector = "Yes";
            else
                GeneratePDF.NCDProtector = "No";

            GeneratePDF.AdditionalDriverCharge = float.Parse(additionaldriverrate.ToString());

            #region "Old Backward Calculation"
            //gstrate = (GeneratePDF.TotalPremium) / 107 * 7;
            //grosspremium = (GeneratePDF.TotalPremium) / 107 * 100;

            //GeneratePDF.GSTRate = float.Parse(gstrate.ToString());
            //GeneratePDF.GrossPremium = float.Parse(grosspremium.ToString());


            //if (_isncdprotect)
            //{
            //    ncdprotectrate = (GeneratePDF.GrossPremium / 110) * 10;
            //}

            //if (_isOFD && Convert.ToInt32(_ncdpercent) >= 30)
            //{
            //    ofdrate = (GeneratePDF.GrossPremium - ncdprotectrate) / 95 * 5;
            //}

            ////if (_ncdpercent == "10" || _ncdpercent == "20" || _ncdpercent == "30")
            ////{
            ////    adddiscrate = (GeneratePDF.GrossPremium - ncdprotectrate) / 95 * 5;
            ////}

            //if (_ncdpercent == "0" || _ncdpercent == "-1")
            //{
            //    ncdrate = 0;
            //    basicpremium = GeneratePDF.GrossPremium;
            //}

            //else if (_ncdpercent == "10")
            //{
            //    ncdrate = ((GeneratePDF.GrossPremium + ofdrate) - ncdprotectrate) / 90 * 10;
            //    basicpremium = (ncdrate / 10) * 100;
            //}
            //else if (_ncdpercent == "20")
            //{
            //    ncdrate = ((GeneratePDF.GrossPremium + ofdrate) - ncdprotectrate) / 80 * 20;
            //    basicpremium = (ncdrate / 20) * 100;
            //}
            //else if (_ncdpercent == "30")
            //{
            //    ncdrate = ((GeneratePDF.GrossPremium + ofdrate) - ncdprotectrate) / 70 * 30;
            //    basicpremium = (ncdrate / 30) * 100;
            //}
            //else if (_ncdpercent == "40")
            //{
            //    ncdrate = ((GeneratePDF.GrossPremium + ofdrate) - ncdprotectrate) / 60 * 40;
            //    basicpremium = (ncdrate / 40) * 100;
            //}
            //else if (_ncdpercent == "50")
            //{
            //    ncdrate = ((GeneratePDF.GrossPremium + ofdrate) - ncdprotectrate) / 50 * 50;
            //    basicpremium = (ncdrate / 50) * 100;
            //}

            ////Sakthi on 11 Jan 2011 -- Start

            //double _Tempbasicpremium = 0;
            //Int32 _NCD = Convert.ToInt32(_ncdpercent);
            //if (_ncdpercent == "0" || _ncdpercent == "-1")
            //{
            //    ncdrate = 0;
            //    _Tempbasicpremium = GeneratePDF.GrossPremium;
            //}
            //else
            //{
            //    _Tempbasicpremium = (ncdrate / _NCD) * 100;
            //}

            //if (_agerestriction == "1")
            //{
            //    basicpremium = ((_Tempbasicpremium / 90) * 100);
            //    _agerestrictionamount = (basicpremium * .1).ToString();
            //}
            //else if (_agerestriction == "2")
            //{
            //    basicpremium = ((_Tempbasicpremium / 92.5) * 100);
            //    _agerestrictionamount = (basicpremium * .075).ToString();
            //}
            ////Sakthi on 11 Jan 2011 -- End


            //GeneratePDF.OFDRate = float.Parse(ofdrate.ToString());
            ////GeneratePDF.AddDiscountRate = float.Parse(adddiscrate.ToString());
            //if (_cxcovertypeid == 5)
            //{
            //    GeneratePDF.TotalPremium -= 321;
            //    GeneratePDF.BuyUpDownRate = 321;
            //}
            //else if (_cxcovertypeid == 6)
            //{
            //    GeneratePDF.TotalPremium -= 160.5f;
            //    GeneratePDF.BuyUpDownRate = 160.5f;
            //}
            //else if (_cxcovertypeid == 7)
            //{
            //    GeneratePDF.TotalPremium -= 642;
            //    GeneratePDF.BuyUpDownRate = 642;
            //}
            //else
            //{
            //    GeneratePDF.BuyUpDownRate = 0;
            //}
            #endregion

            float _orgBasicPremium = Convert.ToSingle(_basicpremium);
            basicpremium = _orgBasicPremium;

            if (_agerestriction == "1")
            {
                _agerestrictionamount = (_orgBasicPremium * 0.1).ToString("#.00"); ;
                _orgBasicPremium -= Convert.ToSingle(_agerestrictionamount);
            }
            else if (_agerestriction == "2")
            {
                _agerestrictionamount = (_orgBasicPremium * 0.075).ToString("#.00"); ;
                _orgBasicPremium -= Convert.ToSingle(_agerestrictionamount);
            }

            if (_ncdpercent != "0" && _ncdpercent != "-1")
            {
                ncdrate = _orgBasicPremium * (Convert.ToSingle(_ncdpercent) / 100f);
                _orgBasicPremium -= ncdrate;

                if (_isOFD && Convert.ToInt32(_ncdpercent) >= 30)
                {
                    ofdrate = _orgBasicPremium * 0.05f;
                    _orgBasicPremium -= ofdrate;
                    GeneratePDF.OFDRate = ofdrate;
                }
            }

            if (_isncdprotect)
            {
                ncdprotectrate = _orgBasicPremium * 0.1f;
                //ncdprotectrate += (ncdprotectrate * 0.07f);
                _orgBasicPremium += ncdprotectrate;
            }

            grosspremium = _orgBasicPremium;
            GeneratePDF.GrossPremium = grosspremium;

            gstrate = _orgBasicPremium * 0.07f;
            _orgBasicPremium += gstrate;

            if (_cxcovertypeid == 5)
            {
                _orgBasicPremium -= 321f;
                gstrate -= 21f;
                GeneratePDF.BuyUpDownRate = 300f;
            }
            else if (_cxcovertypeid == 6)
            {
                _orgBasicPremium -= 160.5f;
                gstrate -= 10.5f;
                GeneratePDF.BuyUpDownRate = 150f;
            }
            else if (_cxcovertypeid == 7)
            {
                _orgBasicPremium -= 642f;
                gstrate -= 42f;
                GeneratePDF.BuyUpDownRate = 600f;
            }
            else
            {
                GeneratePDF.BuyUpDownRate = 0;
            }


            GeneratePDF.GSTRate = gstrate;
            GeneratePDF.TotalPremium = _orgBasicPremium;

            GeneratePDF.NCDDiscountRate = float.Parse(ncdrate.ToString());
            GeneratePDF.NCDProtectorRate = float.Parse(ncdprotectrate.ToString());
            GeneratePDF.BasicPremium = float.Parse(basicpremium.ToString());

            GeneratePDF.AgeRestriction = _agerestriction;
            GeneratePDF.AgeRestrictionAmount = float.Parse(_agerestrictionamount);

            GeneratePDF.CardType = _cctype;
            GeneratePDF.CardNo = _ccno;
            if (rdoCreditCard.Checked)
            {
                //GeneratePDF.CardExpiryDate = Convert.ToDateTime("01-" + _ccexmm + "-" + _ccexyy);
                GeneratePDF.CardExpiryDate = Convert.ToDateTime(_ccexmm + "-" + "01" + "-" + _ccexyy);
            }
            else
            {
                GeneratePDF.CardExpiryDate = CE.Global.General.GetUTCDateTime();
            }
            GeneratePDF.CardholdersName = _nameofcard;
            GeneratePDF.InstallmentType = _installmenttype;
            GeneratePDF.PaymentType = _paymenttype;


            if (UserType == 0)
                GeneratePDF.LibertyPDFProposalForm(_fileName + "-cust", UserType);
            else
                GeneratePDF.LibertyPDFProposalForm(_fileName, UserType);


            //SEND MAIL
            //string _providerEmail = "cherylmae.lanot@teledirect.com.sg"; // CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_TO");
            //string _providerCCEmail = ""; //CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_CC");
            //string _providerBCCEmail = ""; // CE.Configuration.MyConfigurationManager.GetAppSettingValue("HSBCCI_BCC");

            string _filePath = GeneratePDF.GetFilePathLiberty();

            string _pdffile = _filePath + _fileName + ".pdf";

            if (UserType == 0)
                _pdffile = _filePath + _fileName + "-cust.pdf";


            //string _pdffile = Server.MapPath("/pdfoutput/" + _fileName + ".pdf");
            filelist[0] = _pdffile;


            //string _refid = "L" + convertno;
            //MyMailManager.SendCarProposalAttachment("Liberty Insurance", _providerEmail, _providerCCEmail, _providerBCCEmail, "", CE.Global.General.GetUTCDateTime().ToShortDateString(), CE.Global.General.GetUTCDateTime().ToShortTimeString(), _refid, "Liberty", filelist);

        }

        return filelist;

    }

}
